Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Aug 2014 19:36:56 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r270113 - head/bin/sh
Message-ID:  <201408171936.s7HJauxo089643@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408171936.s7HJauxo089643>