Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Jul 2015 05:59:42 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285438 - head/bin/stty
Message-ID:  <201507130559.t6D5xg1I097350@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Mon Jul 13 05:59:41 2015
New Revision: 285438
URL: https://svnweb.freebsd.org/changeset/base/285438

Log:
  Prevent potential integer overflow
  
  PR:		192971
  Submitted by:	David Carlier <david.carlier@hardenedbsd.org>

Modified:
  head/bin/stty/stty.c

Modified: head/bin/stty/stty.c
==============================================================================
--- head/bin/stty/stty.c	Mon Jul 13 05:56:27 2015	(r285437)
+++ head/bin/stty/stty.c	Mon Jul 13 05:59:41 2015	(r285438)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507130559.t6D5xg1I097350>