Author: jilles
Date: Sun Aug 17 19:36:56 2014
New Revision: 270113
URL: http://svnweb.freebsd.org/changeset/base/270113

Log:
  sh: Avoid overflow in atoi() when parsing HISTSIZE.
  
  Side effect: a non-numeric HISTSIZE now results in the default size (100)
  instead of 0.

Modified:
  head/bin/sh/histedit.c

Modified: head/bin/sh/histedit.c
==============================================================================
--- head/bin/sh/histedit.c      Sun Aug 17 19:24:26 2014        (r270112)
+++ head/bin/sh/histedit.c      Sun Aug 17 19:36:56 2014        (r270113)
@@ -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);
        }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to