git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] do not depend on signed integer overflow

From
Jeff King <peff@peff.net>
Date
Oct 5, 2010, 03:43 UTC
Message-ID
<20101005034301.GA23357@coredump.intra.peff.net>
In-Reply-To
<1286232552-5244-1-git-send-email-kusmabite@gmail.com>
On Tue, Oct 05, 2010 at 12:49:12AM +0200, Erik Faye-Lund wrote:
Show 13 quoted lines
> diff --git a/builtin/index-pack.c b/builtin/index-pack.c
> index 2e680d7..e243d9d 100644
> --- a/builtin/index-pack.c
> +++ b/builtin/index-pack.c
> @@ -161,7 +161,7 @@ static void use(int bytes)
>  	input_offset += bytes;
>  
>  	/* make sure off_t is sufficiently large not to wrap */
> -	if (consumed_bytes > consumed_bytes + bytes)
> +	if (signed_add_overflows(consumed_bytes, bytes))
>  		die("pack too large for current definition of off_t");
>  	consumed_bytes += bytes;
>  }

FWIW, I find your new version much easier to read, too (that it fixes a bug is just a nice bonus. ;) ).

-Peff
Previous: Erik Faye-LundNext: Nicolas Pitre
Message 2 of 4 in “do not depend on signed integer overflow”
  1. do not depend on signed integer overflowErik Faye-Lund, Oct 4, 2010
  2. Jeff KingOct 5, 2010
  3. Nicolas PitreOct 5, 2010
  4. Erik Faye-LundOct 5, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.