From: | Marko Kreen <marko(at)l-t(dot)ee> |
---|---|
To: | nconway(at)klamath(dot)dyndns(dot)org, pgsql-hackers(at)postgresql(dot)org, pgman(at)candle(dot)pha(dot)pa(dot)us |
Subject: | Re: Re: bug in pgcrypto 0.3 |
Date: | 2001-05-14 21:47:13 |
Message-ID: | 20010514234712.A21849@l-t.ee |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2001-05-14 21:49:22 | Re: pg_index.indislossy |
Previous Message | The Hermit Hacker | 2001-05-14 21:33:02 | Re: pg_index.indislossy |