]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: parse inode in /proc/pid/maps correctly
authorYonghong Song <yhs@fb.com>
Fri, 25 Jan 2019 21:20:08 +0000 (13:20 -0800)
committerMark Wielaard <mark@klomp.org>
Tue, 29 Jan 2019 20:07:51 +0000 (21:07 +0100)
The inode number in /proc/pid/maps is displayed as "unsigned long"
type.

In one of our x64 system, we have inode number exceeding valid "long"
type range, which caused the following test failure:
   FAIL: dwfl-bug-fd-leak
   FAIL: run-backtrace-dwarf.sh
   FAIL: vdsosyms

The offending map entry:
  7f269246b000-7f269246c000 rw-p 0002e000 00:50 10224326387095067468 /home/...

This patch changed sscanf inode number type from PRIi64 to PRIu64
and fixed the problem.

Signed-off-by: Yonghong Song <yhs@fb.com>
libdwfl/ChangeLog
libdwfl/linux-proc-maps.c

index de45e7f19cde540aec80c125f99cb3e264e6f879..04cadb43c563b69e6b76960eccc30bedc9655a72 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-25  Yonghong Song  <yhs@fb.com>
+
+       * linux-proc-maps.c (proc_maps_report): Use PRIu64, not PRIi64, to
+       read the inode number.
+
 2019-01-20  Mark Wielaard  <mark@klomp.org>
 
        * dwfl_segment_report_module.c (dwfl_segment_report_module): Check
index c4438c0f9534dcf1c48f1cb5fd032116d93ba006..719cba684870b10358c1afb66df494143784e907 100644 (file)
@@ -217,7 +217,7 @@ proc_maps_report (Dwfl *dwfl, FILE *f, GElf_Addr sysinfo_ehdr, pid_t pid)
       uint64_t ino;
       int nread = -1;
       if (sscanf (line, "%" PRIx64 "-%" PRIx64 " %*s %" PRIx64
-                 " %x:%x %" PRIi64 " %n",
+                 " %x:%x %" PRIu64 " %n",
                  &start, &end, &offset, &dmajor, &dminor, &ino, &nread) < 6
          || nread <= 0)
        {