diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-02-11 12:36:41 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-02-11 12:36:41 +0000 |
commit | fb553615789b57887b430cd471e21058952738a8 (patch) | |
tree | dd51202bc06d6548b8e3c87b7840ba879bd9d3d9 /bin/stty | |
parent | f3254bdfd6d92f860a54d0b600c021aac87fd454 (diff) |
use strtonum for ispeed & ospeed, rejecting those numbers.
Diffstat (limited to 'bin/stty')
-rw-r--r-- | bin/stty/key.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/bin/stty/key.c b/bin/stty/key.c index a3574ec1a29..b45d941eb08 100644 --- a/bin/stty/key.c +++ b/bin/stty/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.14 2009/10/28 20:58:38 deraadt Exp $ */ +/* $OpenBSD: key.c,v 1.15 2015/02/11 12:36:40 deraadt Exp $ */ /* $NetBSD: key.c,v 1.11 1995/09/07 06:57:11 jtc Exp $ */ /*- @@ -210,8 +210,13 @@ f_extproc(struct info *ip) void f_ispeed(struct info *ip) { - - cfsetispeed(&ip->t, atoi(ip->arg)); + const char *errstr; + speed_t speed; + + speed = strtonum(ip->arg, 0, UINT_MAX, &errstr); + if (errstr) + err(1, "ispeed %s", ip->arg); + cfsetispeed(&ip->t, speed); ip->set = 1; } @@ -247,8 +252,13 @@ f_nl(struct info *ip) void f_ospeed(struct info *ip) { - - cfsetospeed(&ip->t, atoi(ip->arg)); + const char *errstr; + speed_t speed; + + speed = strtonum(ip->arg, 0, UINT_MAX, &errstr); + if (errstr) + err(1, "ospeed %s", ip->arg); + cfsetospeed(&ip->t, speed); ip->set = 1; } |