Hi 

The problem I (not me - I only post this report for an other guy)
discovered only happens when the input (encoded form)
is not "well" formatted (i.e. exactly 64 characters per line). The
OpenSSL base64 decoder allows inputs containing white spaces and
skip them.

However, due to data buffering, if the last input line contains only
white spaces, the decoding process aborts and returns an error. This
occurs for example on NT with:
- an internal data buffer size of 1024 bytes, and
- input encoded data where each line starts with 7 white spaces,
  giving a total of 73 (7 + 64 + 2 for CRLF) chars per line.
In that particular case, the internal data buffer initially holds
the 14 leading full input lines + the 2 first chars of the 15-th line,
which are spaces...

Attached, you can find the 2 PEMs used for testing:
- pkcs7.pem    (as found in the OpenSSL distribution), and
- pkcs7err.pem (where I added 2 spaces in each line)

Here is also my fix in the module 'encode.c': lines 283-284 have been
replaced by:

/*$PB$ Does not work if the last line in the buffer contains
**     only spaces... Happens for ex. with a buffer size 1024
**     when all lines start with 7 white-space chars!
**
               if (((i+1) == inl) && (((n&3) == 0) || eof))
                       v=B64_EOF;
$PB$*/
               if (((i+1) == inl) && eof)
                       v=B64_EOF;

regards
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to