summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-10-15 13:43:15 +0200
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-10-24 15:32:24 +0200
commitd23978584db9f97fa516c1c64a7bd355962a0467 (patch)
tree68cc57f2494b0c7fdc1d5669116efd40ed9b1942
parent488f0d5c0fcbe5360c3fe0091e191d97455773be (diff)
downloadcrash-worker-d23978584db9f97fa516c1c64a7bd355962a0467.tar.gz
crash-worker-d23978584db9f97fa516c1c64a7bd355962a0467.tar.bz2
crash-worker-d23978584db9f97fa516c1c64a7bd355962a0467.zip
Handle spaces in the crashed app pathname and in the maps file
Change-Id: I98ff537cab9c37b78dc3f3056a375fd10461b7ea
-rw-r--r--src/crash-manager/crash-manager.c2
-rw-r--r--src/crash-stack/crash-stack.c7
-rw-r--r--src/crash-stack/unwind.c8
3 files changed, 14 insertions, 3 deletions
diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c
index 686a13e..a02d59c 100644
--- a/src/crash-manager/crash-manager.c
+++ b/src/crash-manager/crash-manager.c
@@ -692,7 +692,7 @@ static int dump_system_state(const struct crash_info *cinfo)
char command[PATH_MAX];
ret = snprintf(command, sizeof(command),
- "/usr/bin/dump_systemstate -d -k -j -f %s",
+ "/usr/bin/dump_systemstate -d -k -j -f '%s'",
cinfo->log_path);
if (ret < 0) {
_E("Failed to snprintf for dump_systemstate command");
diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c
index bf1cd38..61b876c 100644
--- a/src/crash-stack/crash-stack.c
+++ b/src/crash-stack/crash-stack.c
@@ -62,6 +62,11 @@
#define STRING_FORMAT_SPECIFIER_WITH_MACRO(macro) "%"#macro"s"
#define STR_FS(macro) STRING_FORMAT_SPECIFIER_WITH_MACRO(macro)
+// this macro returns the format specifier to capture a string that can
+// contain spaces
+#define STRINGWW_FORMAT_SPECIFIER_WITH_MACRO(macro) "%"#macro"[^\t\n]"
+#define STRWW_FS(macro) STRINGWW_FORMAT_SPECIFIER_WITH_MACRO(macro)
+
static FILE *outputfile = NULL; ///< global output stream
static FILE *errfile = NULL; ///< global error stream
static FILE *bufferfile = NULL; ///< buffer file for ordering
@@ -377,7 +382,7 @@ static struct addr_node *get_addr_list_from_maps(int fd)
result = sscanf(linebuf, STR_FS(ADDR_LEN)
STR_FS(PERM_LEN)
"%*s %*s %*s"
- STR_FS(PATH_MAX), addr, perm, path);
+ STRWW_FS(PATH_MAX), addr, perm, path);
if (result < 0)
continue;
perm[PERM_LEN] = 0;
diff --git a/src/crash-stack/unwind.c b/src/crash-stack/unwind.c
index bce9ef8..d372bbe 100644
--- a/src/crash-stack/unwind.c
+++ b/src/crash-stack/unwind.c
@@ -861,7 +861,13 @@ void *_TB_create (pid_t pid) {
if (fgets(buf, STAT_LINE_MAXSIZE, f) == NULL)
goto out_err;
- for (i = 0, p = buf; i < 28; i++) {
+ // The filename of the executable (the second field) is in parentheses and can
+ // contain whitespaces. Therefore I'm looking for the last ')' character
+ // and then iterate to the 27 field from here.
+ p = strrchr(buf, ')');
+ if (!p)
+ goto out_err;
+ for (i = 0; i < 27; i++) {
p = strchr(p, ' ');
if (!p)
goto out_err;