diff options
author | bapt <bapt@FreeBSD.org> | 2015-07-13 05:59:41 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-07-13 05:59:41 +0000 |
commit | 610f9926f94603814bd537f4a7d385bd5e386155 (patch) | |
tree | 92db0112eca21a2b13d3a4eba7c2f38d11c512ff /bin/stty | |
parent | cd420706fe34572f88c6bf1739565b844a0ecedf (diff) | |
download | FreeBSD-src-610f9926f94603814bd537f4a7d385bd5e386155.zip FreeBSD-src-610f9926f94603814bd537f4a7d385bd5e386155.tar.gz |
Prevent potential integer overflow
PR: 192971
Submitted by: David Carlier <david.carlier@hardenedbsd.org>
Diffstat (limited to 'bin/stty')
-rw-r--r-- | bin/stty/stty.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/stty/stty.c b/bin/stty/stty.c index b70f49f..26e02e4 100644 --- a/bin/stty/stty.c +++ b/bin/stty/stty.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <err.h> #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -61,7 +62,7 @@ main(int argc, char *argv[]) struct info i; enum FMT fmt; int ch; - const char *file; + const char *file, *errstr = NULL; fmt = NOTSET; i.fd = STDIN_FILENO; @@ -130,7 +131,9 @@ args: argc -= optind; if (isdigit(**argv)) { speed_t speed; - speed = atoi(*argv); + speed = strtonum(*argv, 0, UINT_MAX, &errstr); + if (errstr) + err(1, "speed"); cfsetospeed(&i.t, speed); cfsetispeed(&i.t, speed); i.set = 1; |