upgrade-apply-deltafs: Fix a new files archive decompression bug 05/285205/4
authorAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Wed, 7 Dec 2022 11:38:48 +0000 (12:38 +0100)
committerAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Wed, 14 Dec 2022 13:51:43 +0000 (14:51 +0100)
In rare cases (in deltas without any diffs) "sysytem.7z" archive file
would be the first file in its image directory. In this situation, a
wrong offset for the file (relative to delta) would be assumed, and as
a result a wrong file would be targeted for decompression.

Change-Id: I470854c92f9c0a1afe0bdbae134f4e63347916de

src/upgrade-apply-deltafs/engine/fota_tar.c

index 9452fd9..148f638 100755 (executable)
@@ -232,11 +232,16 @@ int tar_get_cfg_data(tar_info *tar_data)
                return -1;
        }
 
-       off_t last_seek = 0;
+       off_t last_seek;
        int ret;
 
        for(;;)
        {
+               if ((last_seek = tar_seek(tar_data->tar, 0, SEEK_CUR)) < 0) {
+                       LOGE("seeking error!\n");
+                       return -1;
+               }
+
                switch(th_read(tar_data->tar))
                {
                case -1:
@@ -265,11 +270,6 @@ int tar_get_cfg_data(tar_info *tar_data)
                        LOGE("tar_skip_regfile() error!\n");
                        return -1;
                }
-
-               if ((last_seek = tar_seek(tar_data->tar, 0, SEEK_CUR)) < 0) {
-                       LOGE("seeking error!\n");
-                       return -1;
-               }
        }
        return 0;
 }