]> granicus.if.org Git - procps-ng/commitdiff
pmap: empty output or crashes on ppc/s390 caused by wrong pidlist type
authorJaromir Capik <jcapik@redhat.com>
Mon, 4 Feb 2013 17:21:39 +0000 (18:21 +0100)
committerCraig Small <csmall@enc.com.au>
Tue, 5 Feb 2013 11:10:18 +0000 (22:10 +1100)
Previously the pidlist variable was defined as unsigned long *
whilst the openproc function accepts pid_t *.
Both target types differ in size (8 != 4) and therefore the issue
mainly affects big endian architectures.

This commit changes the pidlist type to pid_t * so that it's
compatible with openproc.

pmap.c

diff --git a/pmap.c b/pmap.c
index 7862eace9cf5620fcc54c9eec6bb7c6c2a5c58e4..5a955dff2468d289fccdb72c29c4c80de949faac 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -621,7 +621,7 @@ static void range_arguments(char *optarg)
 
 int main(int argc, char **argv)
 {
-       unsigned long *pidlist;
+       pid_t *pidlist;
        unsigned count = 0;
        PROCTAB *PT;
        proc_t p;
@@ -689,7 +689,7 @@ int main(int argc, char **argv)
            x_option && (d_option || X_option))
                xerrx(EXIT_FAILURE, _("options -d, -x, -X are mutually exclusive"));
 
-       pidlist = xmalloc(sizeof(unsigned long) * argc);
+       pidlist = xmalloc(sizeof(pid_t) * argc);
 
        while (*argv) {
                char *walk = *argv++;