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

[BUG] Integer overflow bug in cache-tree.c

From
YGYiyuan guo <yguoaz@gmail.com>
Date
Oct 25, 2021, 07:39 UTC
Message-ID
<CAM7=BFoQ3-VfES+n-pH7Oukq1PODVbE9Uu9Y-4XuSA5SjQo=uw@mail.gmail.com>

In the file cache-tree.c, the function "static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)" has the following code (link:https://github.com/git/git/blob/9d530dc0024503ab4218fe6c4395b8a0aa245478/cache-tree.c#L592-#L593):

int subtree_nr; subtree_nr = strtol(cp, &ep, 10);

it->subtree_alloc = subtree_nr + 2; CALLOC_ARRAY(it->down, it->subtree_alloc);

The variable subtree_nr is converted from the string buffer. Suppose it equals INT_MAX, the computation of it->subtree_alloc can trigger a signed integer overflow, which is later used to calculate allocation size.

This can cause security problems if the function do_read_index is given a crafted index file.

Message 1 of 1 in “[BUG] Integer overflow bug in cache-tree.c”
  1. Yiyuan guoOct 25, 2021

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.