diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-10-29 04:09:22 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-10-29 04:09:22 +0000 |
commit | 48e72123566c3d7650be6571b80f9f70b41c6724 (patch) | |
tree | 0d23d0de2abdb77ca3971067b7984db08dcd8da6 /bin/ksh/c_ulimit.c | |
parent | f3f5bf3ebf1aaee9195c0d49323beb781e0c1676 (diff) |
Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...
Diffstat (limited to 'bin/ksh/c_ulimit.c')
-rw-r--r-- | bin/ksh/c_ulimit.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/bin/ksh/c_ulimit.c b/bin/ksh/c_ulimit.c index deb26986fc8..153e68d0f79 100644 --- a/bin/ksh/c_ulimit.c +++ b/bin/ksh/c_ulimit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_ulimit.c,v 1.4 1998/01/17 19:00:44 millert Exp $ */ +/* $OpenBSD: c_ulimit.c,v 1.5 1998/10/29 04:09:20 millert Exp $ */ /* ulimit -- handle "ulimit" builtin @@ -34,6 +34,12 @@ extern long ulimit(); #define SOFT 0x1 #define HARD 0x2 +#ifdef RLIM_INFINITY +# define KSH_RLIM_INFINITY RLIM_INFINITY +#else +# define KSH_RLIM_INFINITY ((rlim_t) 1 << (sizeof(rlim_t) * 8 - 1) - 1) +#endif /* RLIM_INFINITY */ + int c_ulimit(wp) char **wp; @@ -156,25 +162,28 @@ c_ulimit(wp) wp += builtin_opt.optind; set = *wp ? 1 : 0; if (set) { - char *p = *wp; - if (all || wp[1]) { bi_errorf("too many arguments"); return 1; } -#ifdef RLIM_INFINITY - if (strcmp(p, "unlimited") == 0) - val = RLIM_INFINITY; - else -#endif /* RLIM_INFINITY */ - if (!isdigit(*p)) { - bi_errorf("\"%s\" is not a valid limit", p); - return 1; - } else { + if (strcmp(wp[0], "unlimited") == 0) + val = KSH_RLIM_INFINITY; + else { long rval; - if (!evaluate(p, &rval, TRUE)) + if (!evaluate(wp[0], &rval, TRUE)) return 1; + /* Avoid problems caused by typos that + * evaluate misses due to evaluating unset + * parameters to 0... + * If this causes problems, will have to + * add parameter to evaluate() to control + * if unset params are 0 or an error. + */ + if (!rval && !digit(wp[0][0])) { + bi_errorf("invalid limit: %s", wp[0]); + return 1; + } val = rval * l->factor; } } |