From 6cacd5bf36094d1e360b6d21885214fac7617bd0 Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Fri, 13 Dec 2024 19:20:19 +0900 Subject: [PATCH] Revert "Fix SVACE issues" 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 --- src/upgrade-apply-deltafs/engine/SS_FSUpdate.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/upgrade-apply-deltafs/engine/SS_FSUpdate.c b/src/upgrade-apply-deltafs/engine/SS_FSUpdate.c index 6ecdf6d..db4b661 100644 --- a/src/upgrade-apply-deltafs/engine/SS_FSUpdate.c +++ b/src/upgrade-apply-deltafs/engine/SS_FSUpdate.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -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); -- 2.34.1