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: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: bug in pgcrypto 0.3
Date: 2001-05-13 02:17:11
Message-ID: 200105130217.f4D2HBk22714@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Applied to 7.1.X and 7.2.

> On Sat, May 12, 2001 at 12:47:33AM -0400, Neil Conway wrote:
> > I've been experimenting with pgcrypto 0.3 (distributed with
> > Postgres 7.1.0), and I think I've found a bug.
> >
> > I compiled Pgcrypto with OpenSSL, using gcc 2.95.4 and
> > OpenSSL 0.9.6a (the latest Debian 'unstable' packages).
>
> > web=> select encode(digest('blah', 'sha1'), 'base64');
> > FATAL 1: pg_encode: overflow, encode estimate too small
> > pqReadData() -- backend closed the channel unexpectedly.
> > This probably means the backend terminated abnormally
> > before or while processing the request.
> > The connection to the server was lost. Attempting reset: Succeeded.
>
> > Is this a bug? Can it be fixed?
>
> This is a bug alright. And a silly one :)
>
> Thanks for reporting. For standalone package apply this
> patch with -p2.
>
> pgsql-hackers: this should get into REL7_1_STABLE.
>
> --
> marko
>
>
> Index: contrib/pgcrypto/encode.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/contrib/pgcrypto/encode.c,v
> retrieving revision 1.4
> diff -u -r1.4 encode.c
> --- contrib/pgcrypto/encode.c 2001/03/22 03:59:10 1.4
> +++ contrib/pgcrypto/encode.c 2001/05/12 08:28:50
> @@ -349,7 +349,7 @@
> uint
> b64_enc_len(uint srclen)
> {
> - return srclen + (srclen / 3) + (srclen / (76 / 2));
> + return srclen + (srclen + 2 / 3) + (srclen / (76 / 2)) + 2;
> }
>
> uint
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
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 Tom Lane 2001-05-13 02:21:42 Re: Re: [COMMITTERS] pgsql/ /README /configure /configure.in /regis ...
Previous Message Tom Lane 2001-05-13 02:05:19 Re: Postgres bug (working with iserverd)