Fix SVACE issues 88/287088/2
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 19 Jan 2023 09:34:55 +0000 (10:34 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 19 Jan 2023 11:19:30 +0000 (12:19 +0100)
Change-Id: Ied2611d4afd457651b41f0aa068c8b230973118f

src/upgrade-apply-deltafs/engine/SS_PatchDelta.h
src/upgrade-apply-deltafs/engine/fota_tar.c
src/upgrade-apply-deltafs/fota_util.c
src/upgrade-apply-deltafs/fota_util.h
src/upgrade-apply-deltafs/ua.c
src/upgrade-apply/main.c

index 5ba32ba..69c6d13 100755 (executable)
@@ -48,5 +48,4 @@ extern void SS_Free(void * pMemBlock);
 extern long SS_CopyFile(const char * strFromPath, const char * strToPath);
 extern long SS_DeleteFolder(const char * strPath);
 extern long SS_DeleteFile(const char * strPath);
-extern int _system_cmd_wait(const char * command);
 #endif
index 30c3e5b..f905f67 100755 (executable)
 // for the sake of simplicity this stays global
 static gzFile gz_tar = NULL;
 
-// the following 6 functions are copied from this same repo, upgrade-apply/main.c
-void fd_cleanup(int *fd)
-{
-       if (!fd || *fd < 0)
-               return;
-       close(*fd);
-}
-
+// the following 5 functions are copied from this same repo, upgrade-apply/main.c
 int gzip_open(const char *pathname, int oflags, ...)
 {
        if (gz_tar != NULL) {
@@ -59,14 +52,9 @@ int gzip_open(const char *pathname, int oflags, ...)
                return -1;
        }
 
-       __attribute__((cleanup(fd_cleanup))) int inner_fd = open(pathname, O_RDONLY);
-       if (inner_fd == -1)
-               return -1;
-
        gz_tar = gzopen(pathname, "r");
        if (gz_tar == NULL)
                return -1;
-       inner_fd = -1;
 
        return 1;
 }
index a4bb78c..41846cf 100755 (executable)
@@ -46,71 +46,3 @@ void _exit_stdio(void)
        if (s_fd_stderr >= 0)
                close(s_fd_stderr);
 }
-
-/*-----------------------------------------------------------------------------
-  _system_cmd_wait
- ----------------------------------------------------------------------------*/
-int _system_cmd_wait(const char *command)
-{
-
-       int pid = 0;
-       int status = 0;
-       char* const environ[2] = {"DISPLAY=:0", NULL };
-
-       if (command == NULL)
-               return -1;
-
-       pid = fork();
-
-       if (pid == -1)
-               return -1;
-
-       if (pid == 0) {
-               char *argv[4];
-               argv[0] = "sh";
-               argv[1] = "-c";
-               argv[2] = (char*)command;
-               argv[3] = 0;
-               execve("/bin/sh", argv, environ);
-               exit(127);
-       }
-
-       do {
-               if (waitpid(pid, &status, 0) == -1) {
-                       if (errno != EINTR)
-                               return -1;
-               } else {
-                       return status;
-               }
-       } while (1);
-}
-
-/*-----------------------------------------------------------------------------
-  _system_cmd_nowait
- ----------------------------------------------------------------------------*/
-int _system_cmd_nowait(const char *command)
-{
-
-       int pid = 0;
-       char* const environ[2] = {"DISPLAY=:0", NULL };
-
-       if (command == NULL)
-               return -1;
-
-       pid = fork();
-
-       if (pid == -1)
-               return -1;
-
-       if (pid == 0) {
-               char *argv[4];
-               argv[0] = "sh";
-               argv[1] = "-c";
-               argv[2] = (char*)command;
-               argv[3] = 0;
-               execve("/bin/sh", argv, environ);
-               exit(127);
-       }
-
-       return 0;
-}
index df1b9c9..6f4ed30 100755 (executable)
@@ -20,8 +20,6 @@
 #define _FOTA_UTIL_H_
 
 extern void _exit_stdio(void);
-extern int _system_cmd_wait(const char *command);
-extern int _system_cmd_nowait(const char *command);
 
 #endif /* _FOTA_UTIL_H_ */
 
index e579224..bc48247 100755 (executable)
@@ -800,6 +800,11 @@ int main(int argc, char **argv)
        dot_pos = strchr(my_opt.archive_file, '.');
        len = (dot_pos - my_opt.archive_file);
        s_part_info.ua_parti_name = (char*)malloc(sizeof(char) * (len + 1));
+       if (s_part_info.ua_parti_name == NULL) {
+               LOG("memory allocation error: %m (%d)\n", errno);
+               ret = UPI_UPDATE_ERROR;
+               goto Results;
+       }
        strncpy(s_part_info.ua_parti_name, my_opt.archive_file, len);
        s_part_info.ua_parti_name[len] = '\0';
 
index 930c2bc..ecde48a 100644 (file)
@@ -212,14 +212,9 @@ int gzip_open(const char *pathname, int oflags, ...)
                return -1;
        }
 
-       __attribute__((cleanup(fd_cleanup))) int inner_fd = open(pathname, O_RDONLY);
-       if (inner_fd == -1)
-               return -1;
-
        gzip_file = gzopen(pathname, "r");
        if (gzip_file == NULL)
                return -1;
-       inner_fd = -1;
 
        return 1;
 }