crash-manager: Create reports with `corrupted_process' prefix when cmdline is corrupted 42/250042/3
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 18 Dec 2020 10:09:21 +0000 (11:09 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 18 Dec 2020 11:33:35 +0000 (12:33 +0100)
Change-Id: I62cd86e70d4d1e347bdadd4d2a2a4fcb448b88d4

src/crash-manager/crash-manager.c

index 3f4c245..e1ac790 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <assert.h>
+#include <ctype.h>
 #include <dirent.h>
 #include <fcntl.h>
 #include <getopt.h>
@@ -388,8 +389,16 @@ void get_proc_name(const char *cmd_line, char *buff, size_t buff_len)
        if (name_len > buff_len - 1)
                name_len = buff_len - 1;
 
-       strncpy(buff, cmd_line, name_len);
+       // cmdline is valid only if it contains characters that can be used to
+       // to generate "valid" crash report name. Characters > 127 are rejected.
+       for (size_t z = 0; z < name_len; z++) {
+               if (!isgraph(cmd_line[z])) {
+                       strncpy(buff, "corrupted_cmdline", buff_len);
+                       return;
+               }
+       }
 
+       strncpy(buff, cmd_line, name_len);
        buff[name_len] = '\0';
 }