mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
proc: fix capture of mapped pathnames
pathnames are listed unescaped in /proc/[pid]/maps, so using %s as the
conversion specifier cuts pathnames off at space characters. Use %[^\n]
instead, to read everything until the end of the line.
Also, the scanf manpage states: "String input conversions store a
terminating null byte ('\0') to mark the end of the input; the maximum
field width does not include this terminator". So set the maximum field
width to 511 instead of 512, to leave one free byte in the buffer for
the terminating null byte.
Fixes #70
This commit is contained in:
@ -101,10 +101,14 @@ sysprof_proc_source_populate_maps (SysprofProcSource *self,
|
||||
gint r;
|
||||
|
||||
r = sscanf (lines[i],
|
||||
"%lx-%lx %*15s %lx %*x:%*x %lu %512s",
|
||||
"%lx-%lx %*15s %lx %*x:%*x %lu %511[^\n]",
|
||||
&start, &end, &offset, &inode, file);
|
||||
file [sizeof file - 1] = '\0';
|
||||
|
||||
/* file has a " (deleted)" suffix if it was deleted from disk */
|
||||
if (g_str_has_suffix (file, " (deleted)"))
|
||||
file [strlen (file) - strlen (" (deleted)")] = '\0';
|
||||
|
||||
if (r != 5)
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user