summaryrefslogtreecommitdiff
path: root/usr.bin/cdio
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2003-04-06 20:50:06 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2003-04-06 20:50:06 +0000
commit86ba96373482e9467bc2c6ef37b5acdf78e7ce80 (patch)
tree269158a581313903ea86cd6311a29da0695a4642 /usr.bin/cdio
parentcf0439a5471f457a324525372f6367da1b1c549f (diff)
Replace a strcpy and associated code with a snprintf whose return
value is checked. Replace an unhelpful usage() with a relevant error message if the argument buffer overflows. ok millert@
Diffstat (limited to 'usr.bin/cdio')
-rw-r--r--usr.bin/cdio/cdio.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/usr.bin/cdio/cdio.c b/usr.bin/cdio/cdio.c
index 1bce609c29d..3c98593ec53 100644
--- a/usr.bin/cdio/cdio.c
+++ b/usr.bin/cdio/cdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cdio.c,v 1.28 2003/02/18 09:42:33 jmc Exp $ */
+/* $OpenBSD: cdio.c,v 1.29 2003/04/06 20:50:05 krw Exp $ */
/* Copyright (c) 1995 Serge V. Vakulenko
* All rights reserved.
@@ -263,18 +263,14 @@ main(int argc, char **argv)
int len;
for (p=buf; argc-->0; ++argv) {
- len = strlen(*argv);
+ len = snprintf(p, buf + sizeof buf - p,
+ "%s%s", (p > buf) ? " " : "", *argv);
- if (p + len >= buf + sizeof (buf) - 1)
- usage();
+ if (len >= buf + sizeof buf - p)
+ errx(1, "argument list too long.");
- if (p > buf)
- *p++ = ' ';
-
- strcpy(p, *argv); /* ok */
p += len;
}
- *p = 0;
arg = parse(buf, &cmd);
return (run(cmd, arg));
}