Hoeteck Wee wrote:
> 
> Hi,
> 
> I'm working on some stand-alone S/MIME, pkcs7 and other related routines
> based on the apps files in the OpenSSL 0.9.6 code. In particular, I'm
> modifying smime.c, pkcs7.c, etc.
> 
> I wrote a function:
> 
> int smime(char **argv, char **outdata, char **outerror)
> 
> that is basically identical to MAIN in smime.c, except that I would like to
> pass the output as a string into *outdata and the error into *outerror.
> 
> To grab *outdata, I'm using: out = BIO_new(BIO_s_mem()); and then
> 
>         if (BIO_get_mem_data(out, outdata) <= 0) {
>           outdata = NULL;
>           BIO_free_all(out);
>         }
> 
> to pull out the data (checking that it returns some value > 0.
> 

You are assuming that the data placed in "outdata" is null terminated.
It does not have to be. The actual length of available data is the
return value from BIO_get_mem_data() and as such 0 is a valid value
meaning no data but < 0 is not, as documented in the BIO_s_mem() manual
page.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.

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

Reply via email to