summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-10-12 23:44:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-10-12 23:44:14 +0000
commitac01df5dc866a446e17a8e4c61dbce6f36c6e192 (patch)
tree24fdb1fc0a184ae4f373cb50e71656a3e85864ac /usr.sbin
parenta5ded65edfd4ea1ad8dfc836e698a8172abb0e21 (diff)
buf oflow, fixed badly in freebsd by tjr, i changed it to give a nice
warning instead of blind truncation; millert ok
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/timed/timedc/timedc-extern.h4
-rw-r--r--usr.sbin/timed/timedc/timedc.c17
2 files changed, 14 insertions, 7 deletions
diff --git a/usr.sbin/timed/timedc/timedc-extern.h b/usr.sbin/timed/timedc/timedc-extern.h
index 271ef057029..5e65ed0cada 100644
--- a/usr.sbin/timed/timedc/timedc-extern.h
+++ b/usr.sbin/timed/timedc/timedc-extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: timedc-extern.h,v 1.6 2003/06/26 21:36:40 deraadt Exp $ */
+/* $OpenBSD: timedc-extern.h,v 1.7 2003/10/12 23:44:13 deraadt Exp $ */
/*-
* Copyright (c) 1993 The Regents of the University of California.
@@ -37,7 +37,7 @@ void bytehostorder(struct tsp *);
void bytenetorder(struct tsp *);
void clockdiff(int, char *[]);
void help(int, char *[]);
-void makeargv(void);
+int makeargv(void);
void msite(int, char *[]);
void quit(int, char *[]);
void testing(int, char *[]);
diff --git a/usr.sbin/timed/timedc/timedc.c b/usr.sbin/timed/timedc/timedc.c
index 7b2bae9b4d5..7ba3b519738 100644
--- a/usr.sbin/timed/timedc/timedc.c
+++ b/usr.sbin/timed/timedc/timedc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: timedc.c,v 1.11 2003/06/26 21:36:40 deraadt Exp $ */
+/* $OpenBSD: timedc.c,v 1.12 2003/10/12 23:44:13 deraadt Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@@ -51,7 +51,8 @@ int trace = 0;
FILE *fd = NULL;
int margc;
int fromatty;
-char *margv[20];
+#define MAX_MARGV 20
+char *margv[MAX_MARGV];
char cmdline[200];
static struct cmd *getcmd(char *);
@@ -133,7 +134,10 @@ main(int argc, char *argv[])
if (cmdline[0] == 0)
break;
- makeargv();
+ if (makeargv()) {
+ printf("?Too many arguments\n");
+ continue;
+ }
if (margv[0] == 0)
continue;
c = getcmd(margv[0]);
@@ -196,14 +200,14 @@ getcmd(char *name)
/*
* Slice a string up into argc/argv.
*/
-void
+int
makeargv(void)
{
char **argp = margv;
char *cp;
margc = 0;
- for (cp = cmdline; *cp;) {
+ for (cp = cmdline; margc < MAX_MARGV - 1 && *cp; ) {
while (isspace(*cp))
cp++;
if (*cp == '\0')
@@ -216,7 +220,10 @@ makeargv(void)
break;
*cp++ = '\0';
}
+ if (margc == MAX_MARGV - 1)
+ return 1;
*argp++ = 0;
+ return 0;
}
#define HELPINDENT (sizeof ("directory"))