svn commit: r265901 - stable/10/sys/kern

Jilles Tjoelker jilles at stack.nl
Mon May 12 17:03:27 UTC 2014


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


More information about the svn-src-all mailing list