fix svace issue & coding rule 77/142677/8 tizen_3.0 submit/tizen_3.0/20170809.110053
authorjkjo92 <jkjo92@samsung.com>
Mon, 7 Aug 2017 04:21:29 +0000 (13:21 +0900)
committerjkjo92 <jkjo92@samsung.com>
Wed, 9 Aug 2017 04:19:21 +0000 (13:19 +0900)
Change-Id: I9e59a3e27d5895ac40dec459251fa2cead7890ec
Signed-off-by: jkjo92 <jkjo92@samsung.com>
common/fido_b64_util.c
common/fido_tlv_util.c
server/fido_app_id_handler.c

index cbb4141..c5fbbd4 100755 (executable)
@@ -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;
        }
 
index b4c9e25..e932001 100755 (executable)
@@ -88,7 +88,7 @@ _tlv_util_decode_reg_assertion(char *tlv_enc)
 
        int r = _fido_b64url_decode((unsigned char *)tlv_enc, in_len, tlv_dec, &tlv_dec_len);
 
-       if (r !=0) {
+       if (r != 0) {
                SAFE_DELETE(tlv_dec);
                return NULL;
        }
index 6c46409..9eba007 100755 (executable)
@@ -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);