Fix maybe-uninitialized error 73/315873/2
authorJakub Wlostowski <j.wlostowski@samsung.com>
Thu, 8 Aug 2024 09:19:31 +0000 (11:19 +0200)
committerJakub Wlostowski <j.wlostowski@samsung.com>
Thu, 8 Aug 2024 11:09:51 +0000 (13:09 +0200)
Change-Id: I32e2b68d7b7851975ccc90a162a9d1603eda884c

src/ckm/unprivileged/key-wrapping.cpp

index bb64730dc56beb4fde509a5e0866cdfa5950eec7..a9bb666e402058325f4d6e1317908c3f5431f4a3 100644 (file)
@@ -833,11 +833,12 @@ int getConcatenatedDataMaxSize(
                const ckmc_hash_algo_e hashAlgo,
                const size_t keySizeRSA,
                const size_t keySizeAES) {
-       size_t hashSize;
+       int ret = 0;
+       size_t hashSize = 0;
        switch(hashAlgo) {
                case CKMC_HASH_NONE:
                        RUNNER_ERROR_MSG("None hash algoritm provided.");
-                       break;
+                       return ret;
                case CKMC_HASH_SHA1:
                        hashSize = 160;
                        break;
@@ -852,9 +853,10 @@ int getConcatenatedDataMaxSize(
                        break;
                default:
                        RUNNER_ERROR_MSG("Unsupported hash algorithm " << hashAlgo);
+                       return ret;
        }
 
-       int ret = keySizeRSA/8 - keySizeAES/8 - 2*hashSize/8 - 2;
+       ret = keySizeRSA/8 - keySizeAES/8 - 2*hashSize/8 - 2;
        if(ret < 0)
                ret = 0;
        return ret;