sh: Avoid overflow in atoi() when parsing HISTSIZE.

Side effect: a non-numeric HISTSIZE now results in the default size (100)
instead of 0.
This commit is contained in:
Jilles Tjoelker 2014-08-17 19:36:56 +00:00
parent 06224a9492
commit ef9e61785a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=270113

View File

@ -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);
}