Validate the string size parameter passed to -s.

Use strtonum() to reject negative sizes instead of core dumping.

PR:		232206
Submitted by:	David Carlier <devnexen@gmail.com>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D17537
This commit is contained in:
John Baldwin 2018-12-10 21:47:19 +00:00
parent d11278054b
commit c1745bf503

View File

@ -71,6 +71,7 @@ main(int ac, char **av)
struct trussinfo *trussinfo;
char *fname;
char **command;
const char *errstr;
pid_t pid;
int c;
@ -118,7 +119,9 @@ main(int ac, char **av)
fname = optarg;
break;
case 's': /* Specified string size */
trussinfo->strsize = atoi(optarg);
trussinfo->strsize = strtonum(optarg, 0, INT_MAX, &errstr);
if (errstr)
errx(1, "maximum string size is %s: %s", errstr, optarg);
break;
case 'S': /* Don't trace signals */
trussinfo->flags |= NOSIGS;