Fix preparing report for applications with too long name 45/215845/5
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Wed, 16 Oct 2019 12:20:47 +0000 (14:20 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Mon, 4 Nov 2019 14:25:09 +0000 (15:25 +0100)
Crash-manager gets the application name from /proc/<pid>/cmdline, but
this value can be modified (e.g. by modify argv[0]), and may be
incorrect. Now report file name is prepared based on the executable
path.

Change-Id: Ia7f3b495bf501a67620888c99d49832e0fd6a23d

src/crash-manager/crash-manager.c
src/crash-manager/so-info.c

index 86396db..8bf424a 100644 (file)
@@ -363,7 +363,7 @@ bool set_crash_info(struct crash_info *cinfo)
                return false;
        }
 
-       if (asprintf(&cinfo->name, "%s_%d_%s", basename(cinfo->cmd_line),
+       if (asprintf(&cinfo->name, "%s_%d_%s", basename(cinfo->cmd_path),
                        cinfo->pid_info, date) == -1) {
                _E("Failed to snprintf for name");
                cinfo->name = NULL;
@@ -582,7 +582,7 @@ static bool execute_minicoredump(struct crash_info *cinfo, int *exit_code)
                        sig_str,                   // %s - number of signal
                        time_str,                  // %t - time of dump
                        "localhost",               // %h - hostname
-                       basename(cinfo->cmd_line), // %e - exe name (need for result filename)
+                       basename(cinfo->cmd_path), // %e - exe name (need for result filename)
                        MINICOREDUMPER_CONFIG_PATH, // config file
                        "-d",
                        cinfo->pfx,            // temp dir
index b449791..a0ae2dc 100644 (file)
@@ -401,6 +401,10 @@ void get_and_save_so_info(char *map_path, char *out_path)
                                break;
                        }
                        ri->app_name = get_app_name_from_path(file_path);
+                       if (ri->app_name == NULL) {
+                               free(ri);
+                               continue;
+                       }
                        ri->build_id = build_id;
                        ri->rpm_info = NULL;
                        pkgs_not_found = g_slist_append(pkgs_not_found, ri);