From owner-svn-src-head@FreeBSD.ORG Sun Aug 17 16:40:30 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7A938A68; Sun, 17 Aug 2014 16:40:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 66A1B2AD4; Sun, 17 Aug 2014 16:40:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7HGeUd5000859; Sun, 17 Aug 2014 16:40:30 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7HGeUut000858; Sun, 17 Aug 2014 16:40:30 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201408171640.s7HGeUut000858@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 17 Aug 2014 16:40:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270102 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2014 16:40:30 -0000 Author: jilles Date: Sun Aug 17 16:40:29 2014 New Revision: 270102 URL: http://svnweb.freebsd.org/changeset/base/270102 Log: sh: Reject integer overflow in number and is_number. Modified: head/bin/sh/mystring.c Modified: head/bin/sh/mystring.c ============================================================================== --- head/bin/sh/mystring.c Sun Aug 17 14:26:12 2014 (r270101) +++ head/bin/sh/mystring.c Sun Aug 17 16:40:29 2014 (r270102) @@ -82,9 +82,17 @@ number(const char *s) int is_number(const char *p) { - do { - if (! is_digit(*p)) + const char *q; + + if (*p == '\0') + return 0; + while (*p == '0') + p++; + for (q = p; *q != '\0'; q++) + if (! is_digit(*q)) return 0; - } while (*++p != '\0'); + if (q - p > 10 || + (q - p == 10 && memcmp(p, "2147483647", 10) > 0)) + return 0; return 1; }