summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2014-08-17 19:36:56 +0000
committerjilles <jilles@FreeBSD.org>2014-08-17 19:36:56 +0000
commit6b7a8c6dec2e04aeff9ee30f019a90aad67f3b8d (patch)
tree6f2a4886d0a823cea9fe9e5c8623482ca0ec5b81 /bin/sh
parenteb80e5e63b6c7558bbfb33b043e56823c2fc31a6 (diff)
downloadFreeBSD-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/sh')
-rw-r--r--bin/sh/histedit.c5
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);
}
OpenPOWER on IntegriCloud