From ef9e61785a7ca949fb97e63fa3463f27e60fe155 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 17 Aug 2014 19:36:56 +0000 Subject: [PATCH] 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(-) diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index a8c376a295f..c65d1c7134e 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); }