Use a more robust idiom When converting sprintf() to snprintf()
don't use the idiom char foo[BUFSIZ]; snprintf(foo, BUFSIZ, ....); but char foo[BUFSIZ]; snprintf(foo, sizeo foo, ....); because this will automatically catch situations where the size of foo is later changed, e.g. like foo[BUFSIZ + 8]; Fix another use of sprintf.
This commit is contained in:
@@ -146,7 +146,7 @@ logStartStop(char *progName, int logfd, int start)
|
||||
/* remove the trailing '\n'... */
|
||||
tstring[strlen(tstring) - 1] = '\0';
|
||||
|
||||
(void) sprintf(buffer, "%s: %s %s\n",
|
||||
(void) snprintf(buffer, sizeof buffer, "%s: %s %s\n",
|
||||
(savedProgName && *savedProgName) ? savedProgName : "logger",
|
||||
start ? "starting" : "terminating",
|
||||
tstring);
|
||||
|
||||
Reference in New Issue
Block a user