summaryrefslogtreecommitdiff
path: root/bin/ksh/c_sh.c
diff options
context:
space:
mode:
authorJared Yanovich <jaredy@cvs.openbsd.org>2008-07-23 16:34:39 +0000
committerJared Yanovich <jaredy@cvs.openbsd.org>2008-07-23 16:34:39 +0000
commit5ca320126480128c815ad7b53fdd90ebc36dd2e4 (patch)
treedb208329c25153921faf70718e089daf1bc4d709 /bin/ksh/c_sh.c
parent23e70fc50082547972f5818951c8059631e3dcd4 (diff)
fix stack abuse in the `time' commmand, using alloc()'d memory instead.
reported by Thorsten Glaser, thanks. ok millert@, earlier version miod@
Diffstat (limited to 'bin/ksh/c_sh.c')
-rw-r--r--bin/ksh/c_sh.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c
index 901e206fd2b..ae5c3cd8352 100644
--- a/bin/ksh/c_sh.c
+++ b/bin/ksh/c_sh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_sh.c,v 1.37 2007/09/03 13:54:23 otto Exp $ */
+/* $OpenBSD: c_sh.c,v 1.38 2008/07/23 16:34:38 jaredy Exp $ */
/*
* built-in Bourne commands
@@ -719,7 +719,6 @@ timex(struct op *t, int f)
struct timeval usrtime, systime, tv0, tv1;
int tf = 0;
extern struct timeval j_usrtime, j_systime; /* computed by j_wait */
- char opts[1];
gettimeofday(&tv0, NULL);
getrusage(RUSAGE_SELF, &ru0);
@@ -735,11 +734,9 @@ timex(struct op *t, int f)
*/
timerclear(&j_usrtime);
timerclear(&j_systime);
- if (t->left->type == TCOM)
- t->left->str = opts;
- opts[0] = 0;
rv = execute(t->left, f | XTIME);
- tf |= opts[0];
+ if (t->left->type == TCOM)
+ tf |= t->left->str[0];
gettimeofday(&tv1, NULL);
getrusage(RUSAGE_SELF, &ru1);
getrusage(RUSAGE_CHILDREN, &cru1);