diff options
author | Jared Yanovich <jaredy@cvs.openbsd.org> | 2008-07-23 16:34:39 +0000 |
---|---|---|
committer | Jared Yanovich <jaredy@cvs.openbsd.org> | 2008-07-23 16:34:39 +0000 |
commit | 5ca320126480128c815ad7b53fdd90ebc36dd2e4 (patch) | |
tree | db208329c25153921faf70718e089daf1bc4d709 /bin/ksh | |
parent | 23e70fc50082547972f5818951c8059631e3dcd4 (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')
-rw-r--r-- | bin/ksh/c_sh.c | 9 | ||||
-rw-r--r-- | bin/ksh/syn.c | 7 |
2 files changed, 9 insertions, 7 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); diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c index dc1d49ed61a..9b7451a318e 100644 --- a/bin/ksh/syn.c +++ b/bin/ksh/syn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syn.c,v 1.27 2006/04/10 14:38:59 jaredy Exp $ */ +/* $OpenBSD: syn.c,v 1.28 2008/07/23 16:34:38 jaredy Exp $ */ /* * shell parser (C version) @@ -364,6 +364,11 @@ get_command(int cf) case TIME: syniocf &= ~(KEYWORD|ALIAS); t = pipeline(0); + if (t) { + t->str = alloc(2, ATEMP); + t->str[0] = '\0'; /* TF_* flags */ + t->str[1] = '\0'; + } t = block(TTIME, t, NOBLOCK, NOWORDS); break; |