Fix vulnerability 09/188409/1 accepted/tizen/5.0/unified/20181102.021528 accepted/tizen/unified/20180905.140113 submit/tizen/20180905.020038 submit/tizen_5.0/20181101.000004
authorSunmin Lee <sunm.lee@samsung.com>
Tue, 21 Aug 2018 08:51:07 +0000 (17:51 +0900)
committerSunmin Lee <sunm.lee@samsung.com>
Wed, 5 Sep 2018 00:23:03 +0000 (09:23 +0900)
- Fix memory leaks

Change-Id: I594edfc2d46fee720819f31618a77a38d9686d0e
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
ss_engine/SS_PatchDelta.c

index 6d8c056..c2dcf33 100755 (executable)
@@ -281,10 +281,11 @@ int SS_UpdateDeltaFS(const char *source_filename, const char *target_filename,
                                LOGL(LOG_SSENGINE, "Source was currupted, Try loading from backup source\n");
 
                                if (SS_LoadFile(target_filename, &target_file) == 0) {
+                                       if (target_file.data)
+                                               SS_Free(target_file.data);
+
                                        if (memcmp(target_file.sha1, target_sha1, SHA_DIGEST_SIZE) == 0) {
                                                LOGL(LOG_SSENGINE, "Patch Already applied\n");
-                                               if (target_file.data)
-                                                       SS_Free(target_file.data);
                                                return S_SS_SUCCESS;
                                        }
                                }
@@ -317,10 +318,11 @@ int SS_UpdateDeltaFS(const char *source_filename, const char *target_filename,
                } else {
                        LOGL(LOG_SSENGINE, "Source was deleted!!\n");
                        if (SS_LoadFile(target_filename, &target_file) == 0) {
+                               if (target_file.data)
+                                       SS_Free(target_file.data);
+
                                if (memcmp(target_file.sha1, target_sha1, SHA_DIGEST_SIZE) == 0) {
                                        LOGL(LOG_SSENGINE, "Patch Already applied\n");
-                                       if (target_file.data)
-                                               SS_Free(target_file.data);
                                        return S_SS_SUCCESS;
                                }
                        }
@@ -330,6 +332,8 @@ int SS_UpdateDeltaFS(const char *source_filename, const char *target_filename,
                                if (memcmp(source_file.sha1, source_sha1, SHA_DIGEST_SIZE) == 0) {
                                        use_backup = 1;
                                        LOGL(LOG_SSENGINE, "Patch Can be applied from using backup file as source\n");
+                                       if (source_file.data)
+                                               SS_Free(source_file.data);
                                } else {
                                        SS_SetUpgradeState(E_SS_FSSRCCURRUPTED);
                                        if (source_file.data)