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

Re: [PATCH v3 1/1] midx.c: fix an integer overflow

From
Jeff King <peff@peff.net>
Date
Mar 24, 2020, 06:01 UTC
Message-ID
<20200324060125.GA610977@coredump.intra.peff.net>
In-Reply-To
<20200323222515.779477-1-damien.olivier.robert+git@gmail.com>
On Mon, Mar 23, 2020 at 11:25:15PM +0100, Damien Robert wrote:
Show 9 quoted lines
> When verifying a midx index with 0 objects, the
>     m->num_objects - 1
> overflows to 4294967295.
> 
> Fix this both by checking that the midx contains at least one oid,
> and also that we don't write any midx when there is no packfiles.
> 
> Update the tests so that we check that `git multi-pack-index write` does
> not write an midx when there is no object.
Thanks, both sides of this make sense.
> ---
> Since I did not receive any guidelines, I did not upload an midx with no
> object to check in the tests. I just modified the current tests to check
> that we don't produce an midx if there is no objects.

I'd be OK with just this, but adding a binary t/t5319/zero-objs.midx would be fine by me, too.

One minor style nit:
Show 10 quoted lines
> @@ -1124,6 +1130,13 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
>  				    i, oid_fanout1, oid_fanout2, i + 1);
>  	}
>  
> +	if (m->num_objects == 0) {
> +		midx_report(_("the midx contains no oid"));
> +		// remaining tests assume that we have objects, so we can
> +		// return here
> +		return verify_midx_error;
> +	}
We prefer /**/ for comments, like:
  /*
   * Remaining tests assume that we have objects, so we can
   * return here.
   */
-Peff
Previous: Damien RobertNext: Junio C Hamano
Message 11 of 17 in “midx.c: fix an integer overflow”
  1. 1/1 midx.c: fix an integer overflowDamien Robert, Feb 28, 2020
  2. Jeff KingFeb 28, 2020
  3. Junio C HamanoFeb 28, 2020
  4. Damien RobertFeb 29, 2020
  5. Damien RobertFeb 29, 2020
  6. 1/1 midx.c: fix an integer overflowDamien Robert, Mar 12, 2020
  7. Damien RobertMar 12, 2020
  8. Derrick StoleeMar 12, 2020
  9. Damien RobertMar 12, 2020
  10. 1/1 midx.c: fix an integer overflowDamien Robert, Mar 23, 2020
  11. Jeff KingMar 24, 2020
  12. Junio C HamanoMar 24, 2020
  13. 1/1 midx.c: fix an integer overflowDamien Robert, Mar 26, 2020
  14. Junio C HamanoMar 26, 2020
  15. Damien RobertMar 28, 2020
  16. Junio C HamanoMar 28, 2020
  17. 1/1 midx.c: fix an integer underflowDamien Robert, Mar 28, 2020

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.