diff options
author | jilles <jilles@FreeBSD.org> | 2014-08-17 19:36:56 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2014-08-17 19:36:56 +0000 |
commit | 6b7a8c6dec2e04aeff9ee30f019a90aad67f3b8d (patch) | |
tree | 6f2a4886d0a823cea9fe9e5c8623482ca0ec5b81 /bin | |
parent | eb80e5e63b6c7558bbfb33b043e56823c2fc31a6 (diff) | |
download | FreeBSD-src-6b7a8c6dec2e04aeff9ee30f019a90aad67f3b8d.zip FreeBSD-src-6b7a8c6dec2e04aeff9ee30f019a90aad67f3b8d.tar.gz |
sh: Avoid overflow in atoi() when parsing HISTSIZE.
Side effect: a non-numeric HISTSIZE now results in the default size (100)
instead of 0.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/histedit.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index a8c376a..c65d1c7 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -166,9 +166,10 @@ sethistsize(const char *hs) HistEvent he; if (hist != NULL) { - if (hs == NULL || *hs == '\0' || - (histsize = atoi(hs)) < 0) + if (hs == NULL || !is_number(hs)) histsize = 100; + else + histsize = atoi(hs); history(hist, &he, H_SETSIZE, histsize); history(hist, &he, H_SETUNIQUE, 1); } |