mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Remove a load of obsolete printf string limits.
In the previous commit I happened to notice a %.150s in a ppl_logevent call, which was probably an important safety precaution a couple of decades ago when that format string was being used for an sprintf into a fixed-size buffer, but now it's just pointless cruft. This commit removes all printf string formatting directives with a compile-time fixed size, with the one exception of a %.3s used to cut out a 3-letter month name in scpserver.c. In cases where the format string in question was already going to an arbitrary-length function like dupprintf or ppl_logevent, that's all I've done; in cases where there was still a fixed-size buffer, I've replaced it with a dynamic buffer and dupprintf.
This commit is contained in:
30
unix/uxpty.c
30
unix/uxpty.c
@ -707,21 +707,29 @@ static void pty_real_select_result(Pty *pty, int fd, int event, int status)
|
||||
close_on_exit = conf_get_int(pty->conf, CONF_close_on_exit);
|
||||
if (close_on_exit == FORCE_OFF ||
|
||||
(close_on_exit == AUTO && pty->exit_code != 0)) {
|
||||
char message[512];
|
||||
message[0] = '\0';
|
||||
if (WIFEXITED(pty->exit_code))
|
||||
sprintf(message, "\r\n[pterm: process terminated with exit"
|
||||
" code %d]\r\n", WEXITSTATUS(pty->exit_code));
|
||||
else if (WIFSIGNALED(pty->exit_code))
|
||||
char *message;
|
||||
if (WIFEXITED(pty->exit_code)) {
|
||||
message = dupprintf(
|
||||
"\r\n[pterm: process terminated with exit code %d]\r\n",
|
||||
WEXITSTATUS(pty->exit_code));
|
||||
} else if (WIFSIGNALED(pty->exit_code)) {
|
||||
#ifdef HAVE_NO_STRSIGNAL
|
||||
sprintf(message, "\r\n[pterm: process terminated on signal"
|
||||
" %d]\r\n", WTERMSIG(pty->exit_code));
|
||||
message = dupprintf(
|
||||
"\r\n[pterm: process terminated on signal %d]\r\n",
|
||||
WTERMSIG(pty->exit_code));
|
||||
#else
|
||||
sprintf(message, "\r\n[pterm: process terminated on signal"
|
||||
" %d (%.400s)]\r\n", WTERMSIG(pty->exit_code),
|
||||
strsignal(WTERMSIG(pty->exit_code)));
|
||||
message = dupprintf(
|
||||
"\r\n[pterm: process terminated on signal %d (%s)]\r\n",
|
||||
WTERMSIG(pty->exit_code),
|
||||
strsignal(WTERMSIG(pty->exit_code)));
|
||||
#endif
|
||||
} else {
|
||||
/* _Shouldn't_ happen, but if it does, a vague message
|
||||
* is better than no message at all */
|
||||
message = dupprintf("\r\n[pterm: process terminated]\r\n");
|
||||
}
|
||||
seat_stdout(pty->seat, message, strlen(message));
|
||||
sfree(message);
|
||||
}
|
||||
|
||||
seat_eof(pty->seat);
|
||||
|
Reference in New Issue
Block a user