]> granicus.if.org Git - procps-ng/commitdiff
pmap avoid SEGV potential with new X/XX detail options
authorJim Warner <james.warner@comcast.net>
Sat, 22 Dec 2012 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Sat, 22 Dec 2012 19:48:36 +0000 (06:48 +1100)
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 faec340719de6db8f64c468cf1dec84ffdd914a3
Author: Dimitrios Apostolou <jimis@gmx.net>
Date:   Thu Sep 27 22:08:04 2012 +1000

Signed-off-by: Jim Warner <james.warner@comcast.net>
pmap.c

diff --git a/pmap.c b/pmap.c
index b33a8fe35403c6ef5144048fd1b3950666af9ce6..e1773457d7720fad8f604cdd3413af6065ae8810 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -318,7 +318,7 @@ loop_end:
                firstmapping = 0;
        }
        /* === PRINT TOTALS === */
-       if (!q_option) {
+       if (!q_option && listhead!=NULL) {
                footer_gap = maxw1+maxw2+maxw3+maxw4+maxw5+5;
                for (i=0; i<footer_gap; i++)
                        putc(' ', stdout);