[NonACR][ITC][TFDF-1749, TFDF-1750, TFDF-1822, TFDF-1823 heap use after free asan... 01/206401/3
authorABHISHEK JAIN <j.abhishek@samsung.com>
Fri, 17 May 2019 09:08:34 +0000 (14:38 +0530)
committershobhit verma <shobhit.v@samsung.com>
Mon, 20 May 2019 08:54:47 +0000 (08:54 +0000)
Change-Id: Ie32574074a19a62df9cd29badaec645f22aa1d36
Signed-off-by: ABHISHEK JAIN <j.abhishek@samsung.com>
src/itc/fido-client/ITs-fido-client-common.h
src/itc/fido-client/ITs-fido-client.c

index 8d26b568039ad967d830add066bacb0fd03da09d..fb4a56bd4564e225f58dd79e3efc7648b02e216b 100755 (executable)
@@ -36,7 +36,7 @@ bool g_bFidoClientNotSupported;
 #define API_NAMESPACE          "FIDOCLIENT_ITC"
 #define FIDOCLIENT_FEATURE                     "http://tizen.org/feature/fido.uaf"
 #define GMAINTIMEOUT                    10000
-#define NUM_GET_TC_TYPE                13
+#define NUM_GET_TC_TYPE                14
 
 
 
@@ -81,6 +81,7 @@ typedef enum
        TC_DISPLAY,
        ICON,
        MATCHER_PROTECTION_METHOD,
+       ATTESTATION,
        MAX_ENUM
 }GET_TC_TYPE;
 
index 081bae28d25889df730c9e7359c9bb0fa77d15b9..c16ebbcbdc6ca6f2a87965acfd954be587bda9c3 100755 (executable)
@@ -16,8 +16,9 @@
 #include "ITs-fido-client-common.h"
 
 //& set: FidoClient
-fido_authenticator_h g_hauth;
 bool g_bCheckCb = false;
+bool g_bAttestationCb = false;
+bool g_bAuthHandle = false;
 bool g_bmsgCheckCb = false;
 static char *g_pjson_reg = "[ { \"header\": { \"upv\": { \"major\": 1, \"minor\": 0 },\"op\":\"Reg\", \"serverData\": \"nwV8EPqS5raZdAgH3GD9Z-ytCA9MkiiWaCsr1GHHNJ2yUh3HaV1HHxd4Z67FefJOD5sQYZvipfg5BavhdWPMecD2SH39aJixoXN9ZaNwRlcftJe9WbtPNDC9q5V9WX7Z5jCwkAwehcI\" }, \"challenge\": \"9pIcUwwrY5eD9o3OwfhkeHLnoIl0vaeJUbxSHMe_XgE\", \"username\":\"ryan\", \"policy\": { \"accepted\": [ [ { \"aaid\": [ \"0001#8001\" ] } ], [ { \"aaid\": [ \"53EC#3101\" ] } ] ] } } ]";
 #define JSON_INVALID_STRING "\{\"improperjson\": []}"
@@ -28,6 +29,34 @@ static char *g_pjson_reg = "[ { \"header\": { \"upv\": { \"major\": 1, \"minor\"
 
 GET_TC_TYPE g_eGet_TC_Type = TITLE;
 
+
+/**
+* @function            fido_client_attestation_type_cb_p
+* @description         Callback Function
+* @parameter           void *fido_auth_attestation_type_e, void *user_data
+* @return                      NA
+*/
+void fido_client_attestation_type_cb_p(fido_auth_attestation_type_e att_type, void *user_data)
+{
+       char *pszAtt = (char *) user_data;
+
+       FPRINTF("[Line : %d][%s] reached inside fido_client_attestation_type_cb_p callback\\n", __LINE__, API_NAMESPACE);
+       if ( strcmp(pszAtt,"DISCOVER RESPONSE") != 0 )
+       {
+               FPRINTF("[Line : %d][%s] value mismatch \\n", __LINE__, API_NAMESPACE);
+               if ( g_pMainLoop )
+               {
+                       g_main_loop_quit(g_pMainLoop);
+               }
+               return;
+       }
+       g_bAttestationCb = true;
+       if ( g_pMainLoop )
+       {
+               g_main_loop_quit(g_pMainLoop);
+       }
+}
+
 /**
 * @function            fido_client_auth_list_cb_p
 * @description         Callback Functionchar *pszTitle =  NULL;
@@ -41,7 +70,7 @@ static void fido_client_auth_list_cb_p(const fido_authenticator_h auth, void *us
        char *pszAaid =  NULL;
        char *pszDescription =  NULL;
        char *pszScheme =  NULL;
-       fido_auth_algo_e get_algo = -1; 
+       fido_auth_algo_e get_algo = -1;
        fido_auth_user_verify_type_e user_ver = -1;
        fido_auth_key_protection_type_e key_protection = -1;
        fido_auth_attachment_hint_e attachment_hint = -1;
@@ -49,14 +78,20 @@ static void fido_client_auth_list_cb_p(const fido_authenticator_h auth, void *us
        fido_auth_tc_display_type_e tc_discplay = -1;
        char *pszIcon = NULL;
        fido_auth_matcher_protection_type_e matcher_protection = -1;
-       
+
+       const char *pszAttStr = "DISCOVER RESPONSE";
+
        if ( auth == NULL )
        {
                FPRINTF("[Line : %d][%s] Callback fido_client_auth_list_cb invoked auth == NULL \\n", __LINE__, API_NAMESPACE);
+               g_bAuthHandle = false;
                return;
        }
-       g_hauth = auth;
+       g_bAuthHandle = true;
+
        g_bCheckCb = true;
+       g_bAttestationCb = false;
+
        FPRINTF("[Line : %d][%s] reached fido_client_auth_list_cb callback\\n", __LINE__, API_NAMESPACE);
 
        //check result
@@ -278,6 +313,24 @@ static void fido_client_auth_list_cb_p(const fido_authenticator_h auth, void *us
                                        stArr_Key_Value[i].bResult = true;
                                }
                                break;
+                       case ATTESTATION:
+
+                               nRet = fido_authenticator_foreach_attestation_type(auth, fido_client_attestation_type_cb_p, pszAttStr);
+                               if(nRet != FIDO_ERROR_NONE)
+                               {
+                                       FPRINTF("[Line : %d][%s] fido_authenticator_foreach_attestation_type API calls return error code = %s , \\n", __LINE__, API_NAMESPACE, FidoClientGetError(nRet));
+                               }
+
+                               else if(!g_bAttestationCb)
+                               {
+                                       FPRINTF("[Line : %d][%s] fido_client_attestation_type_cb_p - Callback not invoked \\n", __LINE__, API_NAMESPACE);
+                               }
+                               else
+                               {
+                                       FPRINTF("[Line : %d][%s] fido_authenticator_foreach_attestation_type API is Passed \\n", __LINE__, API_NAMESPACE);
+                                       stArr_Key_Value[i].bResult = true;
+                               }
+                               break;
                        default:
                                break;
                }
@@ -321,7 +374,7 @@ void ITs_fido_client_startup(void)
        }
 
        g_bCheckCb = false;
-       g_bFidoClientCreation = true;   
+       g_bFidoClientCreation = true;
        FPRINTF("[Line : %d][%s] TEST SUIT start-up: ITs_fido_client_startup\\n", __LINE__, API_NAMESPACE);
 
        // Launch fido-asm service daemon in advance
@@ -362,25 +415,27 @@ void ITs_fido_client_cleanup(void)
 * @apicovered                  fido_foreach_authenticator                                              
 * @passcase                            When fido_foreach_authenticator is successful.
 * @failcase                            If target API bfido_foreach_authenticator fails 
-* @precondition                        
-* @postcondition               
+* @precondition
+* @postcondition
 */
 int ITc_fido_foreach_authenticator_p(void)
 {
        START_TEST;
        g_eGet_TC_Type = MAX_ENUM;
        g_bCheckCb = false;
+       g_bAuthHandle = false;
        int nRet = fido_foreach_authenticator(fido_client_auth_list_cb_p, NULL);
-       PRINT_RESULT(FIDO_ERROR_NONE, nRet, "fido_foreach_authenticator", FidoClientGetError(nRet));    
-       if(g_hauth == NULL)
+       PRINT_RESULT(FIDO_ERROR_NONE, nRet, "fido_foreach_authenticator", FidoClientGetError(nRet));
+
+       if(!g_bCheckCb)
        {
-               FPRINTF("[Line : %d][%s] g_hauth is null  \\n", __LINE__, API_NAMESPACE);
-               
+               FPRINTF("[Line : %d][%s] Callback function not invoked in fido_foreach_authenticator \\n", __LINE__, API_NAMESPACE);
                return 1;
        }
-       else if(!g_bCheckCb)
+
+       if(!g_bAuthHandle)
        {
-               FPRINTF("[Line : %d][%s] Callback function not invoked in fido_foreach_authenticator \\n", __LINE__, API_NAMESPACE);
+               FPRINTF("[Line : %d][%s] auth hanlde recieved in fido_client_auth_list_cb_p as NULL \\n", __LINE__, API_NAMESPACE);
                return 1;
        }
        return 0;
@@ -581,30 +636,7 @@ int ITc_fidoclient_fido_authenticator_getalgorithm_p(void)
        return 0;
 }
 
-/**
-* @function            fido_client_attestation_type_cb_p
-* @description         Callback Function
-* @parameter           void *fido_auth_attestation_type_e, void *user_data
-* @return                      NA
-*/
-void fido_client_attestation_type_cb_p(fido_auth_attestation_type_e att_type, void *user_data)
-{
-       char *pszStr = (char *) user_data;
-
-       if ( strcmp(pszStr,"DISCOVER RESPONSE") != 0 )
-       {
-               FPRINTF("[Line : %d][%s] value mismatch \\n", __LINE__, API_NAMESPACE);
-               return;
-       }
-       FPRINTF("[Line : %d][%s] reached fido_client_attestation_type_cb_p callback\\n", __LINE__, API_NAMESPACE);
-       
-       g_bCheckCb = true;
-       if ( g_pMainLoop )
-       {
-               g_main_loop_quit(g_pMainLoop);
-       }
-}
-//& purpose: Get the attestation_type for Authenticator 
+//& purpose: Get the attestation_type for Authenticator
 //& type: auto
 /**
 * @testcase                    ITc_fido_authenticator_foreach_attestation_type_p
@@ -612,39 +644,42 @@ void fido_client_attestation_type_cb_p(fido_auth_attestation_type_e att_type, vo
 * @author              SRID(shilpa.j)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Get the attestation_type for Authenticator 
-* @scenario                            Get the attestation_type for Authenticator 
-* @apicovered                  fido_authenticator_foreach_attestation_type                                             
+* @description                 Get the attestation_type for Authenticator
+* @scenario                            Get the attestation_type for Authenticator
+* @apicovered                  fido_authenticator_foreach_attestation_type
 * @passcase                            When fido_authenticator_foreach_attestation_type is successful.
 * @failcase                            If target API bundle_encode or bundle_decode fails or any precondition and postcondition API fails
 * @precondition                        Authenticator Handle  must be created
 * @postcondition               Authenticator Handle must be released
 */
+
 int ITc_fido_authenticator_foreach_attestation_type_p(void)
 {
        START_TEST;
 
-       g_eGet_TC_Type = MAX_ENUM;
+       g_eGet_TC_Type = ATTESTATION;
        g_bCheckCb = false;
+       g_bAttestationCb = false;
+
        int nRet = fido_foreach_authenticator(fido_client_auth_list_cb_p, NULL);
-       PRINT_RESULT(FIDO_ERROR_NONE, nRet, "fido_foreach_authenticator", FidoClientGetError(nRet));    
+       PRINT_RESULT(FIDO_ERROR_NONE, nRet, "fido_foreach_authenticator", FidoClientGetError(nRet));
        if(!g_bCheckCb)
        {
                FPRINTF("[Line : %d][%s] Callback function not invoked in fido_foreach_authenticator \\n", __LINE__, API_NAMESPACE);
                return 1;
        }
-       
-       char str[5000] = {0,};
-       str[0] = '\0';
-       strcpy(str, "DISCOVER RESPONSE");
-       g_bCheckCb = false;
-       nRet = fido_authenticator_foreach_attestation_type(g_hauth, fido_client_attestation_type_cb_p, str);
-       PRINT_RESULT(FIDO_ERROR_NONE, nRet, "fido_authenticator_foreach_attestation_type", FidoClientGetError(nRet));
-       if(!g_bCheckCb)
+       if(!g_bAttestationCb)
+       {
+               FPRINTF("[Line : %d][%s] fido_client_attestation_type_cb_p - Callback function not invoked \\n", __LINE__, API_NAMESPACE);
+               return 1;
+       }
+
+       int nIndex = (int)g_eGet_TC_Type;
+       if(stArr_Key_Value[nIndex].bResult == false)
        {
-               FPRINTF("[Line : %d][%s] fido_authenticator_foreach_attestation_type -Callback function not invoked \\n", __LINE__, API_NAMESPACE);
                return 1;
        }
+
        return 0;
 }