]> granicus.if.org Git - procps-ng/commitdiff
Fix off-by-one in pmap
authorCristian Rodríguez <crrodriguez@opensuse.org>
Wed, 22 May 2013 22:22:37 +0000 (18:22 -0400)
committerCristian Rodríguez <crrodriguez@opensuse.org>
Wed, 22 May 2013 22:22:37 +0000 (18:22 -0400)
When procps is built with gcc 4.8 address sanitizer

static int one_proc(proc_t * p)..
..
char smap_key[20];
...
(sscanf(mapbuf, "%20[^:]: %llu", smap_key..

rightfully results in an overflow and the program aborts.

pmap.c

diff --git a/pmap.c b/pmap.c
index 95f365f9b72d98e4d2de25dac1c669a0ff035116..8f111a03bce1f285dc6cf4e4644344f936e30068 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -591,7 +591,7 @@ static int one_proc(proc_t * p)
                unsigned long long file_offset, inode;
                unsigned dev_major, dev_minor;
                unsigned long long smap_value;
-               char smap_key[20];
+               char smap_key[21];
 
                /* hex values are lower case or numeric, keys are upper */
                if (mapbuf[0] >= 'A' && mapbuf[0] <= 'Z') {