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

Checksum incorrectly uses signed values

From
BBBrendan Brewster <brendan.brewster@gmail.com>
Date
Jun 14, 2012, 01:16 UTC
Message-ID
<CA+-ctj5M4XraOQJfWRVVFmRrNsUZUJyt63_Oi__OJCcYMC=ciw@mail.gmail.com>
Hi,

I initially reported this issue to another developer thinking the issue resided there but after some testing and discussion, have found that the issue is not there but possibly here :)

The issue, in summary, is that 7-zip was unable to untar a tar created via a "git archive" whereas gnu tar can. It seem that it may be the case that git is incorrectly using signed values when creating the checksum.

As Igor commented in the other aforementioned thread, "[t]hey use 'char' (that is 'signed char' by default in most compilers). BUT correct TAR must use sum of unsigned values."

Please see the following:
1) The thread previously opened with Igor/7-Zip:
http://sourceforge.net/projects/sevenzip/forums/forum/45798/topic/5322604
2) http://www.gnu.org/software/tar/manual/html_node/Checksumming.html
3) TAR source code:
     tar_checksum
      and
     simple_finish_header
      functions.
4) GIT source code that calculates checksum: ustar_header_chksum
function in archive-tar.c. For reference, here is the snippet of the
git source code in question:
git-git-f623ca1\archive-tar.c
static unsigned int ustar_header_chksum(const struct ustar_header *header)
{
       const char *p = (const char *)header;
       unsigned int chksum = 0;
       while (p < header->chksum)
               chksum += *p++;
       chksum += sizeof(header->chksum) * ' ';
       p += sizeof(header->chksum);
       while (p < (const char *)header + sizeof(struct ustar_header))
               chksum += *p++;
       return chksum;
}
Can someone please look into this and possibly redirect if needed?

Thanks, Brendan

Next: Tomas Carnecky
Message 1 of 3 in “Checksum incorrectly uses signed values”
  1. Brendan BrewsterJun 14, 2012
  2. Tomas CarneckyJun 14, 2012
  3. Brendan BrewsterJun 14, 2012

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.