cvs commit: src/lib/libipsec pfkey_dump.c
Jacques A. Vidrine
nectar at FreeBSD.org
Thu Apr 17 06:08:06 PDT 2003
On Thu, Apr 17, 2003 at 08:23:57AM +0000, Munechika Sumikawa wrote:
> nectar> These sizes seem arbitrary. Previously, at 10 bytes, they were just a
> nectar> bit too small to hold the representation of the largest 32-bit
> nectar> unsigned integer. Now at 20 bytes, they are just a bit too small to
> nectar> hold the representation of the largest 64-bit unsigned integer. This
> nectar> seems sloppy. (As does using a 128 byte buffer to hold the result of
> nectar> concatenating two 20 byte buffers.)
>
> You are right. I've changed to 128 bytes.
Er, that wasn't quite my point :-) My point was that the buffer should
be sized correctly (rather than fudged), such as
char prefbuf[] = "/4294967296";
/* OR */
char prebuf[12];
or whatever you expect the maximum integer to be. [Isn't this a
network prefix? Surely 3 digits is sufficient?]
It just seems like a lot of wastage, but of course it isn't really
important.
> It can be used until we
> support 512bit CPU :-)
Actually 128 bytes is just big enough to hold a NUL-terminated string
representation of a 421-bit unsigned integer. You need 156 bytes for
512 bits :-)
Also, these two 128 byte buffers are still being concatenated into a
single 128 byte buffer, so on average you have room for about 209 bits
:-)
Cheers,
--
Jacques A. Vidrine <nectar at celabo.org> http://www.celabo.org/
NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos
jvidrine at verio.net . nectar at FreeBSD.org . nectar at kth.se
More information about the cvs-src
mailing list