Eric Blake <[EMAIL PROTECTED]> writes: > According to Simon Josefsson on 3/24/2006 4:06 AM: >> FYI: The update of RFC 3548 will include lib/base64.?, so additional >> review of these two files would be appreciated. >> >> See http://josefsson.org/base-encoding/draft-josefsson-rfc3548bis.txt >> for the document. > > The document mentions in 8. that the base 16 alphabet is the standard hex > characters, but the test vectors in 10 show BASE16("f") as "GG" instead of > "66". One of those two sections is therefore wrong.
Oops! My base16 encoder was buggy. I have fixed this in the document now, see: http://josefsson.org/base-encoding/draft-josefsson-rfc3548bis.html#anchor14 > In the comments to base64_encode_alloc, > s/\(memory allocation fail\),/\1ed,/ s/indicate/indicates/ > > Also, the comments state that on allocation failure, base64_encode_alloc > returns BASE64_LENGTH(inlen)+1, but the code only returns > BASE64_LENGTH(inlen). > > Nit - line up the \ in the B64x macro definition. > > isbase64 is not documented. > > In the comments to base64_decode_alloc, s/contain/&s/ > s/function return/&s/g The patch below (installed) should take care of all of that. (Except for lining up the \ in the B64x definition in the document -- I'll do that when I update the source code in the document the next time.) Thank you for your careful review! Regards, Simon --- base64.c 24 Mar 2006 13:34:28 +0100 1.8 +++ base64.c 24 Mar 2006 15:06:28 +0100 @@ -109,8 +109,8 @@ return, the OUT variable will hold a pointer to newly allocated memory that must be deallocated by the caller. If output string length would overflow, 0 is returned and OUT is set to NULL. If - memory allocation fail, OUT is set to NULL, and the return value - indicate length of the requested memory block, i.e., + memory allocation failed, OUT is set to NULL, and the return value + indicates length of the requested memory block, i.e., BASE64_LENGTH(inlen) + 1. */ size_t base64_encode_alloc (const char *in, size_t inlen, char **out) @@ -136,7 +136,9 @@ } *out = malloc (outlen); - if (*out) + if (!*out) + return outlen; + base64_encode (in, inlen, *out, outlen); return outlen - 1; @@ -288,6 +290,8 @@ # define uchar_in_range(c) ((c) <= 255) #endif +/* Return true if CH is a character from the Base64 alphabet, and + false otherwise. */ bool isbase64 (char ch) { @@ -382,11 +386,11 @@ size of the decoded data is stored in *OUTLEN. OUTLEN may be NULL, if the caller is not interested in the decoded length. *OUT may be NULL to indicate an out of memory error, in which case *OUTLEN - contain the size of the memory block needed. The function return + contains the size of the memory block needed. The function returns true on successful decoding and memory allocation errors. (Use the *OUT and *OUTLEN parameters to differentiate between successful - decoding and memory error.) The function return false if the input - was invalid, in which case *OUT is NULL and *OUTLEN is + decoding and memory error.) The function returns false if the + input was invalid, in which case *OUT is NULL and *OUTLEN is undefined. */ bool base64_decode_alloc (const char *in, size_t inlen, char **out, _______________________________________________ bug-gnulib mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-gnulib
