Re: Re: bug in pgcrypto 0.3

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
Cc: nconway(at)klamath(dot)dyndns(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: bug in pgcrypto 0.3
Date: 2001-05-15 04:45:08
Message-ID: 200105150445.f4F4j8s29809@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Applied for 7.1.X and 7.2.

> On Mon, May 14, 2001 at 01:15:59PM -0700, Ian Lance Taylor wrote:
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > > Applied to 7.1.X and 7.2.
> >
> > But, but...
>
> ;)
>
> > > > - return srclen + (srclen / 3) + (srclen / (76 / 2));
> > > > + return srclen + (srclen + 2 / 3) + (srclen / (76 / 2)) + 2;
> >
> > (srclen + 2 / 3) is always the same as (srclen).
> >
> > Perhaps this was meant to be ((srclen + 2) / 3)?
>
> I guess too... Its no good to create patches half-asleep...
>
> > The current code is safe, but weird.
>
> But I got very good response time :)
>
> Well, the correct code - that corresponds to current
> encode - is below. I even got the linefeed stuff wrong.
>
> --
> marko
>
>
>
> Index: contrib/pgcrypto/encode.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/contrib/pgcrypto/encode.c,v
> retrieving revision 1.5
> diff -u -r1.5 encode.c
> --- contrib/pgcrypto/encode.c 2001/05/13 02:17:09 1.5
> +++ contrib/pgcrypto/encode.c 2001/05/14 21:29:43
> @@ -349,7 +349,8 @@
> uint
> b64_enc_len(uint srclen)
> {
> - return srclen + (srclen + 2 / 3) + (srclen / (76 / 2)) + 2;
> + /* 3 bytes will be converted to 4, linefeed after 76 chars */
> + return (srclen + 2) * 4 / 3 + srclen / (76 * 3 / 4);
> }
>
> uint
>

--
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

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2001-05-15 04:52:43 Re: Updating system catalogs after a tuple deletion
Previous Message Tom Lane 2001-05-15 04:42:51 Re: Re: [HACKERS] contrib