Prevent potential integer overflow

PR:		192971
Submitted by:	David Carlier <david.carlier@hardenedbsd.org>
This commit is contained in:
Baptiste Daroussin 2015-07-13 05:59:41 +00:00
parent d4bf4151a5
commit 6f7c45c9d5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285438

View File

@ -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;