From b93fc63044b3ff29486e8ddf4626365e5ff7b170 Mon Sep 17 00:00:00 2001 From: Jooseok Song Date: Tue, 24 Oct 2017 16:13:43 +0900 Subject: [PATCH] Fix svace issue Change-Id: Ie66dba099180086b56611b3c358ac4ae1d6258e5 --- server/fido_app_id_handler.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) mode change 100755 => 100644 server/fido_app_id_handler.c diff --git a/server/fido_app_id_handler.c b/server/fido_app_id_handler.c old mode 100755 new mode 100644 index 23b01fa..d6684e0 --- a/server/fido_app_id_handler.c +++ b/server/fido_app_id_handler.c @@ -402,22 +402,24 @@ __get_pub_key_from_cert(const char *cert_b64) int ret = __b64_decode(cert_b64, strlen(cert_b64), &cert_raw, &cert_raw_len); if (ret != 0) { _ERR("__b64_decode failed"); - free(cert_raw); + SAFE_DELETE(cert_raw); return NULL; } + unsigned char *cert_raw_orig = cert_raw; + X509 *x509 = d2i_X509(NULL, (const unsigned char **)(&cert_raw), cert_raw_len); if (x509 == NULL) { _ERR("d2i_X509 failed"); - free(cert_raw); + SAFE_DELETE(cert_raw_orig); return NULL; } int der_len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x509), NULL); if (der_len <= 0) { _ERR("i2d_X509_PUBKEY failed"); - free(cert_raw); + SAFE_DELETE(cert_raw_orig); return NULL; } @@ -436,7 +438,7 @@ __get_pub_key_from_cert(const char *cert_b64) if (ret != 1) { _ERR("EVP_Digest failed"); OPENSSL_free(der_pubkey); - free(cert_raw); + SAFE_DELETE(cert_raw_orig); return NULL; } @@ -444,7 +446,7 @@ __get_pub_key_from_cert(const char *cert_b64) char *pub_key = __b64_encode(pubkey_der_digest, (int)hashed_len); OPENSSL_free(der_pubkey); - free(cert_raw); + SAFE_DELETE(cert_raw_orig); if (pub_key != NULL) _INFO("%s", pub_key); -- 2.7.4