From owner-svn-src-head@FreeBSD.ORG Sun Aug 15 14:50:03 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7ACEA1065697; Sun, 15 Aug 2010 14:50:03 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6A61D8FC19; Sun, 15 Aug 2010 14:50:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7FEo3vw063367; Sun, 15 Aug 2010 14:50:03 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7FEo3cZ063365; Sun, 15 Aug 2010 14:50:03 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008151450.o7FEo3cZ063365@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Sun, 15 Aug 2010 14:50:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211337 - head/lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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, 15 Aug 2010 14:50:03 -0000 Author: des Date: Sun Aug 15 14:50:03 2010 New Revision: 211337 URL: http://svn.freebsd.org/changeset/base/211337 Log: Fix the overflow test. It is possible for the result of an overflowing shift to be larger than the original value, e.g. (uint64_t)1 << 53 = 0x20000000000000 ((uint64_t)1 << 53) << 10 = 0x8000000000000000 Modified: head/lib/libutil/expand_number.c Modified: head/lib/libutil/expand_number.c ============================================================================== --- head/lib/libutil/expand_number.c Sun Aug 15 14:44:48 2010 (r211336) +++ head/lib/libutil/expand_number.c Sun Aug 15 14:50:03 2010 (r211337) @@ -67,7 +67,7 @@ expand_number(const char *buf, uint64_t } #define SHIFT(n, b) \ - do { if ((n << b) < n) goto overflow; n <<= b; } while (0) + do { if (((n << b) >> b) != n) goto overflow; n <<= b; } while (0) switch (tolower((unsigned char)*endptr)) { case 'e':