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.
For *outerror, I wanted to get the data from bio_err, but I couldn't find a
declaration for it, so I added at the start of the routine:
bio_err = BIO_new(BIO_s_mem());
and
if (BIO_get_mem_data(bio_err, outerror) <= 0) {
outerror = NULL;
}
This seems to work well in most circumstances but occasionally I get extra
characters at the end of *outerror and *outdata. It appears that the
strings *outerror and *outdata were not terminated properly in these cases,
since if I count off the number of bytes returned by BIO_get_mem in the
output, it will stop before reaching these extraneous output.
How could I get around this problem? Is BIO_get_mem_data the right routine
to use? Is this the right way to get the error messages from bio_err? Would
it be safer to do a string copy and return that instead?
(I'm a newbie to C and Unix C development.)
thanks in advance!
-hoeteck
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]