summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-11-07 07:16:16 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-11-07 07:16:16 +0000
commit73c0b1764af2234e43e12e60a44fc1ec766029ff (patch)
tree1dcc47ebdc663d03508bb4f068225ad54ebbd414
parent67dc909e3f215eb757953f61f0ad047728223185 (diff)
Ensure that CU and DV have length > 0, so buf[strlen(buf) - 1] can
be safely called later. Add check for asprintf. Use _PATH_DEV, suggested by jaredy@. OK jaredy@.
-rw-r--r--usr.bin/tip/cu.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c
index bb7183d1c41..e5dbd97a8a2 100644
--- a/usr.bin/tip/cu.c
+++ b/usr.bin/tip/cu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cu.c,v 1.20 2006/11/06 19:37:21 millert Exp $ */
+/* $OpenBSD: cu.c,v 1.21 2006/11/07 07:16:15 ray Exp $ */
/* $NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $ */
/*
@@ -34,9 +34,12 @@
#if 0
static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: cu.c,v 1.20 2006/11/06 19:37:21 millert Exp $";
+static const char rcsid[] = "$OpenBSD: cu.c,v 1.21 2006/11/07 07:16:15 ray Exp $";
#endif /* not lint */
+#include <err.h>
+#include <paths.h>
+
#include "tip.h"
static void cuusage(void);
@@ -87,6 +90,8 @@ getopt:
while ((ch = getopt(argc, argv, "a:l:s:htoe")) != -1) {
switch (ch) {
case 'a':
+ if (optarg[0] == '\0')
+ errx(3, "invalid acu: \"\"");
CU = optarg;
break;
case 'l':
@@ -99,7 +104,8 @@ getopt:
if (strchr(optarg, '/'))
DV = optarg;
else
- asprintf(&DV, "/dev/%s", optarg);
+ if (asprintf(&DV, "%s%s", _PATH_DEV, optarg) == -1)
+ err(3, "asprintf");
break;
case 's':
BR = (int)strtonum(optarg, 0, INT_MAX, &errstr);