pmap avoid SEGV potential with new X/XX detail options

While permissions suggests that /proc/#/smaps contents
are world-readable, in practice this file might not be
available to a non-root process. Whether this is a bug
in the kernel or an intentional design decision really
makes no difference. This commit will protect pmap -X.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit faec340719
Author: Dimitrios Apostolou <jimis@gmx.net>
Date:   Thu Sep 27 22:08:04 2012 +1000

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2012-12-22 00:00:00 -06:00 committed by Craig Small
parent ebf4d6dbba
commit 7e8ee148d7

2
pmap.c
View File

@ -318,7 +318,7 @@ loop_end:
firstmapping = 0; firstmapping = 0;
} }
/* === PRINT TOTALS === */ /* === PRINT TOTALS === */
if (!q_option) { if (!q_option && listhead!=NULL) {
footer_gap = maxw1+maxw2+maxw3+maxw4+maxw5+5; footer_gap = maxw1+maxw2+maxw3+maxw4+maxw5+5;
for (i=0; i<footer_gap; i++) for (i=0; i<footer_gap; i++)
putc(' ', stdout); putc(' ', stdout);