From d06debb088318cefea304bdcc695e7a060a6cdd2 Mon Sep 17 00:00:00 2001 From: imp Date: Thu, 4 Dec 1997 02:54:05 +0000 Subject: Buffer overflow from bitblt's commit to OpenBSD. Committed here for lack of a better place to do it. Reviewed by: joerge Obtained from: OpenBSD --- contrib/top/screen.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'contrib/top') diff --git a/contrib/top/screen.c b/contrib/top/screen.c index b5d0388..531a4f3 100644 --- a/contrib/top/screen.c +++ b/contrib/top/screen.c @@ -204,7 +204,8 @@ int interactive; PC = (PCptr = tgetstr("pc", &bufptr)) ? *PCptr : 0; /* set convenience strings */ - (void) strcpy(home, tgoto(cursor_motion, 0, 0)); + (void) strncpy(home, tgoto(cursor_motion, 0, 0), sizeof(home) - 1); + home[sizeof(home) - 1] = '\0'; /* (lower_left is set in get_screensize) */ /* get the actual screen size with an ioctl, if needed */ @@ -420,7 +421,9 @@ get_screensize() #endif /* TIOCGSIZE */ #endif /* TIOCGWINSZ */ - (void) strcpy(lower_left, tgoto(cursor_motion, 0, screen_length - 1)); + (void) strncpy(lower_left, tgoto(cursor_motion, 0, screen_length - 1), + sizeof(lower_left) - 1); + lower_left[sizeof(lower_left) - 1] = '\0'; } standout(msg) -- cgit v1.1