Fix calloc return check 44/36544/1
authorRadoslaw Bartosiak <r.bartosiak@samsung.com>
Mon, 9 Mar 2015 18:13:22 +0000 (19:13 +0100)
committerRadoslaw Bartosiak <r.bartosiak@samsung.com>
Mon, 9 Mar 2015 19:05:31 +0000 (20:05 +0100)
Handle null returned by calloc.

Change-Id: If2f8085893d283b663f5928f93b90728b175b679
Signed-off-by: Radoslaw Bartosiak <r.bartosiak@samsung.com>
src/dukgen.c

index 86a2e4d..6a76c68 100644 (file)
@@ -30,6 +30,8 @@ char* GetDeviceUniqueKey(char* pAppId, int idLen, int keyLen)
        bool result = true;
 
        pUniqueKey = (unsigned char*)calloc(keyLen,1);
+       if (pUniqueKey == NULL)
+               return NULL;
        result = SecFrameGeneratePlatformUniqueKey((unsigned int)keyLen , pUniqueKey);
        if(result == false)
        {
@@ -38,6 +40,11 @@ char* GetDeviceUniqueKey(char* pAppId, int idLen, int keyLen)
        }
 
        pDuk = (char*)calloc(keyLen, 1);
+       if (pDuk == NULL)
+       {
+               free(pUniqueKey);
+               return NULL;
+       }
        PKCS5_PBKDF2_HMAC_SHA1(pAppId, idLen, (unsigned char*)pUniqueKey, keyLen, 1, keyLen, (unsigned char*)pDuk);
        free(pUniqueKey);