Change-Id: I62cd86e70d4d1e347bdadd4d2a2a4fcb448b88d4
*/
#include <assert.h>
+#include <ctype.h>
#include <dirent.h>
#include <fcntl.h>
#include <getopt.h>
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';
}