summaryrefslogtreecommitdiff
path: root/usr.bin/gcore
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2006-03-25 01:14:20 +0000
committerPeter Wemm <peter@FreeBSD.org>2006-03-25 01:14:20 +0000
commit045b6fdaf67c39935e1ee89d178fb33f25230a97 (patch)
treea59b74d8256339f5c4a72c635fca84c92b92f273 /usr.bin/gcore
parent4b8b545e4ba40b8cd2571eb2b01721ccd6289af3 (diff)
downloadsrc-test2-045b6fdaf67c39935e1ee89d178fb33f25230a97.tar.gz
src-test2-045b6fdaf67c39935e1ee89d178fb33f25230a97.zip
Make gcore(1) 64 bit safe. It was trying to parse the /proc/*/map file
using sscanf and truncating the start/end entries by writing them with a 32 bit int descriptor (%x). The upper bytes of the 64 bit vm_offset_t variables (for little endian machines) were uninitialized. For big endian machines, things would have been worse because it was storing the 32 bit value in the upper half of the 64 bit variable. I've changed it to use %lx and long types. That should work on all our platforms.
Notes
Notes: svn path=/head/; revision=157109
Diffstat (limited to 'usr.bin/gcore')
-rw-r--r--usr.bin/gcore/elfcore.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c
index 4a920eb0246f..00b32862708f 100644
--- a/usr.bin/gcore/elfcore.c
+++ b/usr.bin/gcore/elfcore.c
@@ -495,15 +495,15 @@ readmap(pid_t pid)
linkp = &map;
while (pos < mapsize) {
vm_map_entry_t ent;
- vm_offset_t start;
- vm_offset_t end;
+ u_long start;
+ u_long end;
char prot[4];
char type[16];
int n;
int len;
len = 0;
- n = sscanf(mapbuf + pos, "%x %x %*d %*d %*x %3[-rwx]"
+ n = sscanf(mapbuf + pos, "%lx %lx %*d %*d %*x %3[-rwx]"
" %*d %*d %*x %*s %*s %16s %*s%*[\n]%n",
&start, &end, prot, type, &len);
if (n != 4 || len == 0)