Hi,

The example code that comes with openssl comes with a file 'selfsign.c' 
which I used to generate a key.  I modified the line that calls 
X509_gmtime_adj to 100 years because I didn't care about key expiry 
(this is probably the wrong way to do it, but...).

This generated a large negative adjustment, which isn't trapped by the 
function until it gets to ASN1_GENERALIZEDTIME_set.  There, the call to 
OPENSSL_gmtime fails and is initialised with random junk from the stack 
- the 'data' variable is passed into this function uninitialised, and if 
gmtime() fails it just returns it as the result without checking).

This random junk is then sprintf()ed into a fixed length buffer of 20 
bytes, but the resulting string on my machine is 47 bytes, causing 
failure of the app a few lines later.

It seems that only the Win32 gmtime() returns NULL if its argument is 
negative... gcc seems to return valid data, however NULL is a valid 
return value and should be checked for & handled correctly.

Tony

-- 
"When I am working on a problem I never think about beauty. I only think
  about how to solve the problem. But when I have finished, if the solution
  is not beautiful, I know it is wrong." -- Buckminster Fuller

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

Reply via email to