diff options
author | wosch <wosch@FreeBSD.org> | 1998-08-24 16:25:30 +0000 |
---|---|---|
committer | wosch <wosch@FreeBSD.org> | 1998-08-24 16:25:30 +0000 |
commit | 184c377af2dc581f60d15b7a84651cd16c04f83c (patch) | |
tree | 97b130473b38b244be4d269044f8084332bcb7bc /usr.bin/gcore/gcore.c | |
parent | 8a3c521f04ee9ad807d4c737f050230cb04ce36d (diff) | |
download | FreeBSD-src-184c377af2dc581f60d15b7a84651cd16c04f83c.zip FreeBSD-src-184c377af2dc581f60d15b7a84651cd16c04f83c.tar.gz |
Check the text segment size of the executable and the process. If
not equal, the command line arguments are wrong. E.g.:
$./gcore /bin/sh 1761
$ ./gcore /usr/tmp/chroot/bin/sh 1761
gcore: The executable /usr/tmp/chroot/bin/sh does not belong to process 1761!
Text segment size (in bytes): executable 303104, process 294912
Diffstat (limited to 'usr.bin/gcore/gcore.c')
-rw-r--r-- | usr.bin/gcore/gcore.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/gcore/gcore.c b/usr.bin/gcore/gcore.c index 3f8ccb9..46ef21e 100644 --- a/usr.bin/gcore/gcore.c +++ b/usr.bin/gcore/gcore.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)gcore.c 8.2 (Berkeley) 9/23/93"; #endif static const char rcsid[] = - "$Id: gcore.c,v 1.6 1997/07/08 11:04:17 charnier Exp $"; + "$Id: gcore.c,v 1.7 1997/11/18 03:50:25 jdp Exp $"; #endif /* not lint */ /* @@ -162,6 +162,14 @@ main(argc, argv) errx(1, "%s exec header: %s", argv[0], cnt > 0 ? strerror(EIO) : strerror(errno)); + /* check the text segment size of the executable and the process */ + if (exec.a_text != ptoa(ki->kp_eproc.e_vm.vm_tsize)) + errx(1, + "The executable %s does not belong to process %d!\n" + "Text segment size (in bytes): executable %d, process %d", + argv[0], pid, exec.a_text, + ptoa(ki->kp_eproc.e_vm.vm_tsize)); + data_offset = N_DATOFF(exec); if (sflag && kill(pid, SIGSTOP) < 0) |