Re: pgcryto failures on freebsd/alpha

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgcryto failures on freebsd/alpha
Date: 2002-01-03 07:23:25
Message-ID: 200201030723.g037NPE21358@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Patch applied because it is to /contrib and is from the author, and
fixes some unusual code. Did testing the bottom two bits actually test
anything (res & 3)?

---------------------------------------------------------------------------

Marko Kreen wrote:
> On Thu, Jan 03, 2002 at 01:13:55AM -0500, Bruce Momjian wrote:
> > Marko Kreen wrote:
> > > On Fri, Dec 21, 2001 at 11:43:21AM +0800, Christopher Kings-Lynne wrote:
> > > > Just testing pgcrypto on freebsd/alpha. I get some warnings:
> > > They should be harmless, although I should fix them.
> >
> > The actual code is:
> >
> > if ((dlen & 15) || (((unsigned) res) & 3))
> > return -1;
>
> > Hard to imagine how (uint *) & 3 makes any sense, unless res isn't
> > always a (uint8 *). Is that true?
>
> At some point it was casted to (uint32*) so I wanted to be sure its ok.
> ATM its pointless. Please apply the following patch.
>
> --
> marko
>
>
> Index: contrib/pgcrypto/internal.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/internal.c,v
> retrieving revision 1.10
> diff -u -r1.10 internal.c
> --- contrib/pgcrypto/internal.c 20 Nov 2001 18:54:07 -0000 1.10
> +++ contrib/pgcrypto/internal.c 21 Dec 2001 08:45:21 -0000
> @@ -311,7 +311,7 @@
> if (dlen == 0)
> return 0;
>
> - if ((dlen & 15) || (((unsigned) res) & 3))
> + if (dlen & 15)
> return -1;
>
> memcpy(res, data, dlen);
> @@ -339,7 +339,7 @@
> if (dlen == 0)
> return 0;
>
> - if ((dlen & 15) || (((unsigned) res) & 3))
> + if (dlen & 15)
> return -1;
>
> memcpy(res, data, dlen);
> @@ -426,7 +426,7 @@
> if (dlen == 0)
> return 0;
>
> - if ((dlen & 7) || (((unsigned) res) & 3))
> + if (dlen & 7)
> return -1;
>
> memcpy(res, data, dlen);
> @@ -450,7 +450,7 @@
> if (dlen == 0)
> return 0;
>
> - if ((dlen & 7) || (((unsigned) res) & 3))
> + if (dlen & 7)
> return -1;
>
> memcpy(res, data, dlen);
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Kreen 2002-01-03 07:36:05 Re: pgcryto failures on freebsd/alpha
Previous Message Marko Kreen 2002-01-03 07:21:05 Re: pgcryto failures on freebsd/alpha