We're getting the serial number of the certificate from openssl and
freeing it with ast_free(), but it needs to be freed with OPENSSL_free()
instead. Now we duplicate the string and free the one from openssl with
OPENSSL_free(), which means we can still use ast_free() on the returned
string.
https://wiki.asterisk.org/wiki/display/AST/OpenSIPit+2021
Change-Id: Ia6e1a4028c1933a0e1d204b769ebb9f5a11f00ab
ASN1_INTEGER *serial;
BIGNUM *bignum;
char *serial_hex;
+ char *ret;
fp = fopen(path, "r");
if (!fp) {
return NULL;
}
- return serial_hex;
+ ret = ast_strdup(serial_hex);
+ OPENSSL_free(serial_hex);
+ if (!ret) {
+ ast_log(LOG_ERROR, "Failed to dup serial from openssl for certificate %s\n", path);
+ return NULL;
+ }
+
+ return ret;
}