From owner-svn-src-stable-10@FreeBSD.ORG Mon May 12 17:03:27 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 19071EC3; Mon, 12 May 2014 17:03:27 +0000 (UTC) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D04882ABE; Mon, 12 May 2014 17:03:26 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 1726C3592DF; Mon, 12 May 2014 19:03:23 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 048B428497; Mon, 12 May 2014 19:03:23 +0200 (CEST) Date: Mon, 12 May 2014 19:03:22 +0200 From: Jilles Tjoelker To: Andrey Chernov Subject: Re: svn commit: r265901 - stable/10/sys/kern Message-ID: <20140512170322.GA2479@stack.nl> References: <201405120427.s4C4RAZf093033@svn.freebsd.org> <5370F110.5050502@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5370F110.5050502@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-stable@freebsd.org, Don Lewis , src-committers@freebsd.org, svn-src-stable-10@freebsd.org, svn-src-all@freebsd.org X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 May 2014 17:03:27 -0000 On Mon, May 12, 2014 at 08:04:32PM +0400, Andrey Chernov wrote: > On 12.05.2014 8:27, Don Lewis wrote: > > + if (start + amask < start) { > > + DPRINTF(("start+amask wrapped around\n")); > > + goto out; > > + } > Checking for overflow _after_ it happens is unportable and dangerous, > since wrapping around is not only one possible result. They should be > rewritten like that: > if (start > ULONG_MAX - amask) Unsigned types wrap around per the C standard. Overflow checking after it happens is fine. You are right for signed types. -- Jilles Tjoelker