diff options
author | John Baldwin <jhb@FreeBSD.org> | 2018-12-10 21:47:19 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2018-12-10 21:47:19 +0000 |
commit | c1745bf5036da58631cce53d78c9b3a09d648ddf (patch) | |
tree | 6ce71687062fdf0a0dbeeb4268b90f63966f2a28 /usr.bin/truss | |
parent | d11278054b9a35ea86ba33793454bab0d0893ead (diff) | |
download | src-c1745bf5036da58631cce53d78c9b3a09d648ddf.tar.gz src-c1745bf5036da58631cce53d78c9b3a09d648ddf.zip |
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
Notes
Notes:
svn path=/head/; revision=341802
Diffstat (limited to 'usr.bin/truss')
-rw-r--r-- | usr.bin/truss/main.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index 9ba7968828fc..c10301b6680d 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -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; |