diff options
author | Jared Yanovich <jaredy@cvs.openbsd.org> | 2005-07-01 19:33:36 +0000 |
---|---|---|
committer | Jared Yanovich <jaredy@cvs.openbsd.org> | 2005-07-01 19:33:36 +0000 |
commit | d9b9ae6c927021d6e6128256fe197d0335c83572 (patch) | |
tree | 6303e738028194ecb3e568be1f69745809c653ff /usr.bin/top | |
parent | 92ab15d29618dd968fdab5ee0be18ce4e5c3f7c7 (diff) |
NUL-terminate the screen buffer in u_process(), since it is passed to
strlen() in line_buffer() (requires allocating an extra byte for it).
from markus, ok deraadt
Diffstat (limited to 'usr.bin/top')
-rw-r--r-- | usr.bin/top/display.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index 616cd4c47e3..2214ba759fa 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.21 2005/06/17 12:12:28 markus Exp $ */ +/* $OpenBSD: display.c,v 1.22 2005/07/01 19:33:35 jaredy Exp $ */ /* * Top users/processes display for Unix @@ -138,7 +138,7 @@ display_resize(void) display_width = MAX_COLS - 1; /* now, allocate space for the screen buffer */ - screenbuf = malloc(display_lines * display_width); + screenbuf = malloc(display_lines * display_width + 1); if (screenbuf == NULL) return (-1); @@ -675,6 +675,7 @@ u_process(int linenum, char *linebuf) /* truncate the line to conform to our current screen width */ linebuf[display_width] = '\0'; + bufferline[display_width] = '\0'; /* is line higher than we went on the last display? */ if (linenum >= last_hi) { |