Revert "Fix SVACE issues" 69/316569/1 accepted/tizen/unified/20241216.185847 accepted/tizen/unified/x/20241218.032717 accepted/tizen/unified/x/asan/20241224.004443
authorSangYoun Kwak <sy.kwak@samsung.com>
Fri, 13 Dec 2024 10:20:19 +0000 (19:20 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Fri, 13 Dec 2024 10:20:57 +0000 (19:20 +0900)
Since the original code was OK but the SVACE issue was false positive,
revert it and return to the original code.

Below is an explanation why the original is OK:
The second parameter of lseek() is __off64_t, which is a 64-bit signed
integer and the type of dwPosition is unsigned int, which is a 32-bit
unsigned integer. Since 64-bit signed integer can represent all possible
values of 32-bit unsigned integer, it is OK to use dwPosition as the
second parameter of lseek().
The issue says that __off64_t is long type, but it is only when the
build architecture is 64-bit. When the build architecture is 32-bit the
__off64_t is defined as __int64_t which is 64-bit signed integer.
Thus, the issue of the patch 2d5b2b6 is false positive and patch should
be reverted.

This reverts commit 2d5b2b6fc3a1a9cb45976a47565a03b3f6d6e515.

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

index 6ecdf6d7b4948489f86334fb9d8156f7ffc20414..db4b661dec304e224d322fd7edcf21f8cdde97d8 100644 (file)
@@ -30,7 +30,6 @@
 #include <string.h>
 #include <strings.h>
 #include <sys/wait.h>
-#include <stdint.h>
 
 #include <ftw.h>
 #include <sys/xattr.h>
@@ -386,12 +385,8 @@ SS_WriteFile(long wHandle,
 
        LOGL(LOG_SSENGINE, "Handle:%ld , Pos:%u , Size: %u\n", wHandle,
                        dwPosition, dwSize);
-       if (dwPosition > INT64_MAX) {
-               LOGE("Position value exceeds 64-bit signed range: %u", dwPosition);
-               return E_SS_WRITE_ERROR;
-       }
-       __off64_t position = (__off64_t)dwPosition;
-       ret = lseek(wHandle, position, SEEK_SET);
+
+       ret = lseek(wHandle, dwPosition, SEEK_SET);
        if (ret < 0) {
                LOGE(" lseek failed with return value: %d\n", ret);
                LOGL(LOG_SSENGINE, "lseek errno=%d\n", errno);
@@ -474,12 +469,7 @@ SS_ReadFile(long wHandle,
        LOG(" %s: Handle:%ld , Pos:%u , Size: %u", __func__, wHandle,
               dwPosition, dwSize);
 #endif
-       if (dwPosition > INT64_MAX) {
-               LOGE("Position value exceeds 64-bit signed range: %u", dwPosition);
-               return E_SS_WRITE_ERROR;
-       }
-       __off64_t position = (__off64_t)dwPosition;
-       ret = lseek(wHandle, position, SEEK_SET);
+       ret = lseek(wHandle, dwPosition, SEEK_SET);
        if (ret < 0) {
                LOGE("Handle:%ld , Pos:%u , Size: %u\n", wHandle, dwPosition,
                     dwSize);