From 6b7a8c6dec2e04aeff9ee30f019a90aad67f3b8d Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 17 Aug 2014 19:36:56 +0000 Subject: sh: Avoid overflow in atoi() when parsing HISTSIZE. Side effect: a non-numeric HISTSIZE now results in the default size (100) instead of 0. --- bin/sh/histedit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bin') 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); } -- cgit v1.1