Hi,

I have below 2 functions


1.      Received the certificate data is DER format and convert to X509 format


RetCode convert_der_to_x509(uint8_t *cert_der, uint32_t cert_len)
{
  const unsigned char  *bptr = NULL;

  X509  *x509 = NULL;
  bptr = (unsigned char *)cert_der;
  x509 = d2i_X509(NULL, &bptr, cert_len);               /*x509 structure is 
allocated here*/
  if (x509 == NULL)
  {
    syfer_log->ERR("DER to x509 converion failed");
    return RET_ERROR;
  }
  return RET_SUCCESS;
}


2.      Clean up the X509 structure


Void cleanup_x509()
{
  X509_free(x509);
}

Query:
When I call the cleanup_x509 function:

I get the memory crash

Backtrace:
Program terminated with signal 11, Segmentation fault.
#0  0x081e7748 in ASN1_STRING_free ()
#0  0x081e7748 in ASN1_STRING_free ()
#1  0x081e2b90 in ASN1_primitive_free ()
#2  0x081e2b7a in ASN1_primitive_free ()
#3  0x081e2c1a in asn1_item_combine_free ()
#4  0x081e2e5d in ASN1_template_free ()
#5  0x081e2d9e in asn1_item_combine_free ()
#6  0x081e2e5d in ASN1_template_free ()
#7  0x081e2d9e in asn1_item_combine_free ()
#8  0x081e2e93 in ASN1_item_free ()
#9  0x081defd7 in X509_free ()
#10 0x08052673 in CertificateRemote::cleanup_x509 (this=0x9bb55f0) at 
syfer/crypto/Certificate.cpp:309

What could be possible reason for the above crash ?


Thanks,
Sanjay

Reply via email to