Skip to content

Commit

Permalink
r336028 changed next_msg to a char * from char [] of fixed size. Change
Browse files Browse the repository at this point in the history
2nd argument of vsnprintf() to get the strlen of next_msg so that the
appropriate size is used.

Found with gcc.

/usr.bin/top/display.c: In function 'new_message':
/usr.bin/top/display.c:963:31: error:
argument to 'sizeof' in 'vsnprintf' call is the same expression as the
destination; did you mean to provide an explicit length?
[-Werror=sizeof-pointer-memaccess]
     vsnprintf(next_msg, sizeof(next_msg), msgfmt, args);

Reviewed by:	daichi
  • Loading branch information
seanbruno committed Jul 6, 2018
1 parent 32f0fef commit 9d5352c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion usr.bin/top/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ new_message(int type, const char *msgfmt, ...)
va_start(args, msgfmt);

/* first, format the message */
vsnprintf(next_msg, sizeof(next_msg), msgfmt, args);
vsnprintf(next_msg, strlen(next_msg), msgfmt, args);

va_end(args);

Expand Down

0 comments on commit 9d5352c

Please sign in to comment.