SS_FSUpdate: Fix to cast into bigger type before operation 14/317314/1
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 30 Dec 2024 09:38:41 +0000 (18:38 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Mon, 30 Dec 2024 09:38:41 +0000 (18:38 +0900)
Since the operands are int, SS_UINT32(unsigned int) and long type, it is
required to cast them into a big enough type before adding them.
(Thier value are all non-negative values)

To resolve this issue, operands are casted to uint64_t, which is big
enough to store the value of the variables and the result of the
arithmetic operation.

Change-Id: Iecf8ffa3be11984ce6fdc3d850f9b9c9f74c7186
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
src/upgrade-apply-deltafs/engine/SS_FSUpdate.c

index db4b661dec304e224d322fd7edcf21f8cdde97d8..08d585cfbda5930a8d68e65dd5682b4cb2594292 100644 (file)
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <strings.h>
 #include <sys/wait.h>
+#include <stdint.h>
 
 #include <ftw.h>
 #include <sys/xattr.h>
@@ -484,7 +485,7 @@ SS_ReadFile(long wHandle,
                return E_SS_READ_ERROR;
        }
 
-       if ((unsigned int)ret != dwSize && (((unsigned long)ret + (unsigned long)dwPosition) != (unsigned long)SS_GetFileSize(wHandle)))
+       if ((unsigned int)ret != dwSize && (((uint64_t)ret + (uint64_t)dwPosition) != (uint64_t)SS_GetFileSize(wHandle)))
                return E_SS_READ_ERROR;
 
        pbBuffer[ret] = '\0';