Skip to content

Commit

Permalink
procfs: fix format of maps file
Browse files Browse the repository at this point in the history
The commit ab6a9af replacing
osv::fprintf() with osv::sprintf() introduced a bug in the
/proc/self/maps content formatting that causes wrong limits
to get printed:

0000000e1000-0000000e3000 r--p 00000000 652925e:ef2fe932 26 /cat
0000000e3000-0000000e7000 r-xp 00002000 652925e:ef2fe932 26 /cat

vs

1000000e1000-1000000e3000 r--p 00000000 6182828:898a8198 26 /cat
1000000e3000-1000000e7000 r-xp 00002000 6182828:898a8198 26 /cat

This patch fixes the problem by adjusting sprintf() format string.

Signed-off-by: Waldemar Kozaczuk <[email protected]>
  • Loading branch information
wkozaczuk committed Nov 12, 2024
1 parent c49fefe commit c16f17b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/mmu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,7 @@ std::string procfs_maps()
char write = vma.perm() & perm_write ? 'w' : '-';
char execute = vma.perm() & perm_exec ? 'x' : '-';
char priv = 'p';
output += osv::sprintf("%012x-%012x %c%c%c%c ", vma.start(), vma.end(), read, write, execute, priv);
output += osv::sprintf("%lx-%lx %c%c%c%c ", vma.start(), vma.end(), read, write, execute, priv);
if (vma.flags() & mmap_file) {
const file_vma &f_vma = static_cast<file_vma&>(vma);
unsigned dev_id_major = major(f_vma.file_dev_id());
Expand Down

0 comments on commit c16f17b

Please sign in to comment.