Fix coverity issue 75/224775/1 accepted/tizen/unified/20200214.050319 submit/tizen/20200213.062745
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Thu, 13 Feb 2020 04:25:24 +0000 (13:25 +0900)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Thu, 13 Feb 2020 04:28:49 +0000 (13:28 +0900)
- increase bufsize to prevent out of bound access
- check null before fwrite

Change-Id: I94571b42c10c1fe10bce9ec6532872b42a9a6196
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
ss_engine/SS_PatchDelta.c
ss_engine/SS_UPI.c

index 9b4c7db2b567426aa2b243b7a68c534b785a5f9d..372f8500275d75c6008277b3f024ebb95422f1fe 100755 (executable)
@@ -610,6 +610,12 @@ int SS_UpdateDeltaKernel(ua_dataSS_t * ua_dataSS, int (*write_to_blkdev) (char *
                goto Cleanup;
        }
        //write source kernel data to workspace
+       if (!source_file.data) {
+               LOGE("source_file.data is null before fwrite");
+               result = E_SS_FAILURE;
+               goto Cleanup;
+       }
+
        read_count = fwrite(source_file.data, 1, source_file.size, fp);
        if (read_count != source_file.size) {
                LOGE("file write error read_count = %d for [%s]\n", read_count, source_filename);
index 9c51ed3fc683058b0b525bcf33bbb31f4a1051fd..2606414a092a55947f7ce56b4e2cf07626af116d 100755 (executable)
@@ -424,7 +424,7 @@ int SS_GetUpgradeState()
 int SS_Get_last_update_status(int* last_update_status, int* del_type)
 {
        int fd;
-       unsigned char buf[256];
+       unsigned char buf[257];
        char *ptr = NULL;
        char *saveptr = NULL;
        int result = 0;
@@ -440,7 +440,7 @@ int SS_Get_last_update_status(int* last_update_status, int* del_type)
                return -1;
        }
 
-       result = SS_ReadFile(fd, 0, buf, sizeof(buf));
+       result = SS_ReadFile(fd, 0, buf, sizeof(buf)-1);
        if (result != 0) {
                LOGE("SS_ReadFile failed!!\n");
                result = SS_CloseFile(fd);