Jeremie Le Hen wrote:
% char   *tls_serial_number(X509 *peer)
% {
%         ASN1_INTEGER *sn;
%         BIGNUM bn;
%         char *bnstr, *snstr;
%         size_t len;
% % if ((sn = X509_get_serialNumber(peer)) == 0)
%                 return (0);
%         ASN1_INTEGER_to_BN(sn, &bn);
This can not work, you can not avoid dynamic allocation of bn.
You are telling openssl to reuse the value inside bn, that will be random content from the stack. You might make it work by initialising bn to zero, but you'd depend for it to work on details of the internal working of ASN1_INTEGER_to_BN

Use either :
BIGNUM *bn;
bn = ASN1_INTEGER_to_BN(sn, NULL);
BN_free(bn);

or
BIGNUM  *bn= NULL;
ASN1_INTEGER_to_BN(sn, bn);
BN_free(bn);

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

Reply via email to