Erroneous check for '\0' in b4encode()?

Help
gogo
2005-09-13
2013-04-23
  • gogo

    gogo - 2005-09-13

    An early check in b64encode() (base64.c:256) appears as follows:

    if (*s == '\0')    return calloc(1, sizeof(*t));

    I'm finding that this line is causing b64encode() to fail to process data (in my case, SHA-1 digests) that happen to begin with "0x00".  The input data should not be assumed to be a character string, so IMO, this check end-of-string check should be omitted.

    Jed

     
    • Bob Deblier

      Bob Deblier - 2005-09-14

      Thanks for reporting - this is a known problem and has been fixed in the CVS.

       
    • gogo

      gogo - 2005-09-14

      Thanks, Bob.  Another issue (which seems also to be present in the version checked into CVS), this time regarding the end of the data that I pass into b64encode(): When I pass in a SHA-1 digest (exactly 20 bytes), the penultimate Base-64-encoded character (i.e. prior to the last "=") is wrong.  I found that if I padded the end of my data with an extra byte set to "0x0", the correct Base-64 encoding comes out.  Is the function making an assumption that the data is null-terminated?  Thanks again.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks