From a591d43cbe858d50b93d9ad5c3fadfb5cd810907 Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Tue, 26 Sep 2017 13:01:13 +0900 Subject: [PATCH] Sync up with tizen branch including svace and coding rule fix Change-Id: Id5ba089e3fb0b359cf03a471ef7e7fee808dcf90 Signed-off-by: jkjo92 --- common/fido_b64_util.c | 7 +++++++ common/fido_internal_types.h | 1 - server/fido_app_id_handler.c | 28 +++++++++++++++++++++++++--- 3 files changed, 32 insertions(+), 4 deletions(-) mode change 100644 => 100755 common/fido_b64_util.c mode change 100644 => 100755 common/fido_internal_types.h diff --git a/common/fido_b64_util.c b/common/fido_b64_util.c old mode 100644 new mode 100755 index cbb4141..c5fbbd4 --- a/common/fido_b64_util.c +++ b/common/fido_b64_util.c @@ -40,6 +40,11 @@ _fido_b64url_encode(const unsigned char *input, int inlen, unsigned char *outpu BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); bmem = BIO_new(BIO_s_mem()); + if (bmem == NULL) { + _ERR("BIO_new with BIO_s_mem failed "); + BIO_free(b64); + return -1; + } b64 = BIO_push(b64, bmem); BIO_write(b64, input, inlen); BIO_flush(b64); @@ -113,6 +118,7 @@ _fido_b64url_decode(const unsigned char *in, int inlen, unsigned char *out, int _ERR("BIO_new_mem_buf failed"); SAFE_DELETE(base64); + BIO_free(b64); return -1; } @@ -122,6 +128,7 @@ _fido_b64url_decode(const unsigned char *in, int inlen, unsigned char *out, int _ERR("BIO_read failed"); SAFE_DELETE(base64); + BIO_free_all(b64); return -1; } diff --git a/common/fido_internal_types.h b/common/fido_internal_types.h old mode 100644 new mode 100755 index 8109920..9bce8dc --- a/common/fido_internal_types.h +++ b/common/fido_internal_types.h @@ -123,7 +123,6 @@ typedef struct _match_criteria { GList *attestation_type_list; int auth_version; GList *extension_list; - } _match_criteria_t; void _free_match_criteria(_match_criteria_t *data); diff --git a/server/fido_app_id_handler.c b/server/fido_app_id_handler.c index dc38c69..23b01fa 100755 --- a/server/fido_app_id_handler.c +++ b/server/fido_app_id_handler.c @@ -333,6 +333,12 @@ __b64_encode(unsigned char *input, int ip_len) BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); bmem = BIO_new(BIO_s_mem()); + if (bmem == NULL) { + _ERR("BIO_new failed \n"); + free(output); + BIO_free(b64); + return NULL; + } b64 = BIO_push(b64, bmem); BIO_write(b64, input, ip_len); BIO_flush(b64); @@ -341,8 +347,7 @@ __b64_encode(unsigned char *input, int ip_len) memcpy(output, bptr->data, bptr->length); output[bptr->length] = 0; - if (b64) - BIO_free_all(b64); + BIO_free_all(b64); return (char*)output; } @@ -358,8 +363,17 @@ __b64_decode(const char *encoded_data, int encoded_size, unsigned char **decoded (*decoded_data) = (unsigned char *) calloc((*decoded_size) * 1.5, sizeof(char)); BIO *bmem = BIO_new_mem_buf((void *) encoded_data, (*decoded_size)); + if (bmem == NULL) { + _ERR("BIO_new failed \n"); + return -1; + } BIO *bioCmd = BIO_new(BIO_f_base64()); + if (bioCmd == NULL) { + _ERR("BIO_new failed \n"); + BIO_free(bmem); + return -1; + } BIO_set_flags(bioCmd, BIO_FLAGS_BASE64_NO_NL); @@ -422,6 +436,7 @@ __get_pub_key_from_cert(const char *cert_b64) if (ret != 1) { _ERR("EVP_Digest failed"); OPENSSL_free(der_pubkey); + free(cert_raw); return NULL; } @@ -429,6 +444,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); if (pub_key != NULL) _INFO("%s", pub_key); @@ -575,6 +591,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati */ cb_data->caller_app_id = __get_tz_facet_id_of_caller(app_id, invocation); if (cb_data->caller_app_id == NULL) { + SAFE_DELETE(app_id); SAFE_DELETE(cb_data); return FIDO_ERROR_PERMISSION_DENIED; } @@ -588,6 +605,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati _DBG("UAF msg does not have appID"); cb_data->real_app_id = __get_tz_facet_id_of_caller(app_id, invocation); g_timeout_add(2, __timer_expired, cb_data); + SAFE_DELETE(app_id); return FIDO_ERROR_NONE; } @@ -597,7 +615,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati cb_data->real_app_id = strdup(uaf_app_id); g_timeout_add(2, __timer_expired, cb_data); - + SAFE_DELETE(app_id); return FIDO_ERROR_NONE; } @@ -606,6 +624,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati _INFO("soup_uri_new failed"); _free_app_id_cb_data(cb_data); + SAFE_DELETE(app_id); return FIDO_ERROR_PERMISSION_DENIED; } @@ -616,11 +635,13 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati const char *scheme = soup_uri_get_scheme(parsed_uri); if (scheme == NULL) { _free_app_id_cb_data(cb_data); + SAFE_DELETE(app_id); return FIDO_ERROR_INVALID_PARAMETER; } if (strcmp(SOUP_URI_SCHEME_HTTPS, scheme) != 0) { _free_app_id_cb_data(cb_data); + SAFE_DELETE(app_id); return FIDO_ERROR_INVALID_PARAMETER; } @@ -653,5 +674,6 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati _INFO("Added in soup_session_queue_message"); + SAFE_DELETE(app_id); return FIDO_ERROR_NONE; } -- 2.7.4