summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2001-08-28 21:27:36 +0000
committerjoerg <joerg@FreeBSD.org>2001-08-28 21:27:36 +0000
commitc9d495ceb8e26eeb351f24457f70c10e3ac9ea61 (patch)
tree12ad15fe76143502a10414398f68e67a4d7cfcc3 /usr.bin/truss
parenteda113cf152e791a3f365da5000c104a42de9cfb (diff)
downloadFreeBSD-src-c9d495ceb8e26eeb351f24457f70c10e3ac9ea61.zip
FreeBSD-src-c9d495ceb8e26eeb351f24457f70c10e3ac9ea61.tar.gz
In get_string(), 0-terminate the contents of buf ``just in case'';
otherwise, if the very first fgetc() already yielded EOF, the returned string won't get terminated at all. MFC after: 1 day
Diffstat (limited to 'usr.bin/truss')
-rw-r--r--usr.bin/truss/syscalls.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 29e8c29..cd92deb 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -124,6 +124,7 @@ get_string(int procfd, void *offset, int max) {
err(1, "fdopen");
buf = malloc( size = (max ? max : 64 ) );
len = 0;
+ buf[0] = 0;
fseek(p, (long)offset, SEEK_SET);
while ((c = fgetc(p)) != EOF) {
buf[len++] = c;
OpenPOWER on IntegriCloud