summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2009-10-28 20:58:38 +0000
committerderaadt <deraadt@openbsd.org>2009-10-28 20:58:38 +0000
commit848c799ecbdec65425e8d062aa337d1edcff8611 (patch)
tree7adbcbf415f93a2ae624fdbe687953537a0e7565
parentDon't catch a signal if we inherited it as ignored. Instigated by (diff)
downloadwireguard-openbsd-848c799ecbdec65425e8d062aa337d1edcff8611.tar.xz
wireguard-openbsd-848c799ecbdec65425e8d062aa337d1edcff8611.zip
Use strtonum() instead of atoi() so that ridiculous sloppy things like
ispeed -38400 baud; ospeed 38400 baud; 24 rows; 80 columns; and % stty rows -45; stty size 65491 80 don't happen. ok millert guenther
-rw-r--r--bin/stty/key.c13
-rw-r--r--bin/stty/stty.c8
2 files changed, 16 insertions, 5 deletions
diff --git a/bin/stty/key.c b/bin/stty/key.c
index 22af3088caa..a3574ec1a29 100644
--- a/bin/stty/key.c
+++ b/bin/stty/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.13 2009/10/27 23:59:22 deraadt Exp $ */
+/* $OpenBSD: key.c,v 1.14 2009/10/28 20:58:38 deraadt Exp $ */
/* $NetBSD: key.c,v 1.11 1995/09/07 06:57:11 jtc Exp $ */
/*-
@@ -35,6 +35,7 @@
#include <err.h>
#include <errno.h>
#include <stdlib.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
@@ -155,8 +156,11 @@ f_cbreak(struct info *ip)
void
f_columns(struct info *ip)
{
+ const char *error;
- ip->win.ws_col = atoi(ip->arg);
+ ip->win.ws_col = strtonum(ip->arg, 0, USHRT_MAX, &error);
+ if (error)
+ err(1, "cols %s", ip->arg);
ip->wset = 1;
}
@@ -265,8 +269,11 @@ f_raw(struct info *ip)
void
f_rows(struct info *ip)
{
+ const char *error;
- ip->win.ws_row = atoi(ip->arg);
+ ip->win.ws_row = strtonum(ip->arg, 0, USHRT_MAX, &error);
+ if (error)
+ err(1, "rows %s", ip->arg);
ip->wset = 1;
}
diff --git a/bin/stty/stty.c b/bin/stty/stty.c
index 210a7368393..04e8f5eb413 100644
--- a/bin/stty/stty.c
+++ b/bin/stty/stty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stty.c,v 1.13 2009/10/27 23:59:22 deraadt Exp $ */
+/* $OpenBSD: stty.c,v 1.14 2009/10/28 20:58:38 deraadt Exp $ */
/* $NetBSD: stty.c,v 1.11 1995/03/21 09:11:30 cgd Exp $ */
/*-
@@ -38,6 +38,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include <unistd.h>
@@ -111,9 +112,12 @@ args: argc -= optind;
continue;
if (isdigit(**argv)) {
+ const char *error;
int speed;
- speed = atoi(*argv);
+ speed = strtonum(*argv, 0, INT_MAX, &error);
+ if (error)
+ err(1, "%s", *argv);
cfsetospeed(&i.t, speed);
cfsetispeed(&i.t, speed);
i.set = 1;