summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2015-09-06 20:07:46 +0000
committertobias <tobias@openbsd.org>2015-09-06 20:07:46 +0000
commita1c4e90abc6223c75821a7a78de781ab4c6844ee (patch)
tree0cb256c32d8985be4e0253d4dfedf332bd94db9f
parentAvoid floating point exception when an invalid font width was specified. (diff)
downloadwireguard-openbsd-a1c4e90abc6223c75821a7a78de781ab4c6844ee.tar.xz
wireguard-openbsd-a1c4e90abc6223c75821a7a78de781ab4c6844ee.zip
UINT_MAX would overflow the integer calculation later on, leading to
floating point exception just like -1 would do. Use INT_MAX, which is already way too high to make sense anyway.
-rw-r--r--usr.sbin/wsfontload/wsfontload.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/wsfontload/wsfontload.c b/usr.sbin/wsfontload/wsfontload.c
index 313d4e9d240..6c279f0587a 100644
--- a/usr.sbin/wsfontload/wsfontload.c
+++ b/usr.sbin/wsfontload/wsfontload.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsfontload.c,v 1.15 2015/09/06 19:56:43 tobias Exp $ */
+/* $OpenBSD: wsfontload.c,v 1.16 2015/09/06 20:07:46 tobias Exp $ */
/* $NetBSD: wsfontload.c,v 1.2 2000/01/05 18:46:43 ad Exp $ */
/*
@@ -105,14 +105,15 @@ main(int argc, char *argv[])
wsdev = optarg;
break;
case 'w':
- f.fontwidth = strtonum(optarg, 1, UINT_MAX, &errstr);
+ f.fontwidth = strtonum(optarg, 1, INT_MAX, &errstr);
if (errstr)
errx(1, "font width is %s: %s", errstr, optarg);
break;
case 'h':
- f.fontheight = strtonum(optarg, 1, UINT_MAX, &errstr);
+ f.fontheight = strtonum(optarg, 1, INT_MAX, &errstr);
if (errstr)
- errx(1, "font height is %s: %s", errstr, optarg);
+ errx(1, "font height is %s: %s",
+ errstr, optarg);
break;
case 'e':
f.encoding = getencoding(optarg);