From owner-svn-src-head@FreeBSD.ORG Mon Jun 21 12:50:54 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 9FD681065673; Mon, 21 Jun 2010 12:50:54 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8F6CF8FC25; Mon, 21 Jun 2010 12:50:54 +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 o5LCosTd027117; Mon, 21 Jun 2010 12:50:54 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5LCosXr027115; Mon, 21 Jun 2010 12:50:54 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201006211250.o5LCosXr027115@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Mon, 21 Jun 2010 12:50:54 +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: r209392 - head/sbin/geom/misc 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: Mon, 21 Jun 2010 12:50:54 -0000 Author: ae Date: Mon Jun 21 12:50:54 2010 New Revision: 209392 URL: http://svn.freebsd.org/changeset/base/209392 Log: Check for overflow before it occurs. Also add check for negative numbers. Suggested by: ache Approved by: kib (mentor) Modified: head/sbin/geom/misc/subr.c Modified: head/sbin/geom/misc/subr.c ============================================================================== --- head/sbin/geom/misc/subr.c Mon Jun 21 10:43:13 2010 (r209391) +++ head/sbin/geom/misc/subr.c Mon Jun 21 12:50:54 2010 (r209392) @@ -139,7 +139,7 @@ g_parse_lba(const char *lbastr, unsigned assert(sectors != NULL); number = (off_t)strtoimax(lbastr, &s, 0); - if (s == lbastr) + if (s == lbastr || number < 0) return (EINVAL); mult = 1; @@ -187,7 +187,7 @@ sfx: if (*s != '\0') return (EINVAL); done: - if (mult * unit < mult || number * mult * unit < number) + if ((OFF_MAX / unit) < mult || (OFF_MAX / mult / unit) < number) return (ERANGE); number *= mult * unit; if (number % sectorsize)