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

Re: [PATCH] Tolerate zlib deflation with window size < 32Kb

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 3, 2011, 23:56 UTC
Message-ID
<7vsjpi82x7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1312410730-12261-1-git-send-email-roberto.tyley@gmail.com>
roberto.tyley@gmail.com writes:
Show 29 quoted lines
> +	 * We must determine if the buffer contains the standard
> +	 * zlib-deflated stream or the experimental format based
> +	 * on the in-pack object format. Compare the header byte
> +	 * for each format:
> +	 *
> +	 * RFC1950 zlib w/ deflate : 0www1000 : 0 <= www <= 7
> +	 * Experimental pack-based : Stttssss : ttt = 1,2,3,4
> +	 *
> +	 * If bit 7 is clear and bits 0-3 equal 8, the buffer MUST be
> +	 * in standard loose-object format, UNLESS it is a Git-pack
> +	 * format object *exactly* 8 bytes in size when inflated.
> +	 *
> +	 * However, RFC1950 also specifies that the 1st 16-bit word
> +	 * must be divisible by 31 - this checksum tells us our buffer
> +	 * is in the standard format, giving a false positive only if
> +	 * the 1st word of the Git-pack format object happens to be
> +	 * divisible by 31, ie:
> +	 *      ((byte0 * 256) + byte1) % 31 = 0
> +	 *   =>        0ttt10000www1000 % 31 = 0
> +	 *
> +	 * As it happens, this case can only arise for www=3 & ttt=1
> +	 * - ie, a Commit object, which would have to be 8 bytes in
> +	 * size. As no Commit can be that small, we find that the
> +	 * combination of these two criteria (bitmask & checksum)
> +	 * can always correctly determine the buffer format.
>  	 */
>  	word = (map[0] << 8) + map[1];
> -	if (map[0] == 0x78 && !(word % 31))
> +	if ((map[0] & 0x88) == 0x08 && !(word % 31))
Are you sure about this 0x88? Isn't it 0x8F or something?
>  		return 0;
>  	else
>  		return 1;
Previous: roberto.tyley@gmail.comNext: Roberto Tyley
Message 2 of 8 in “Tolerate zlib deflation with window size < 32Kb”
  1. Tolerate zlib deflation with window size < 32Kbroberto.tyley@gmail.com, Aug 3, 2011
  2. Junio C HamanoAug 3, 2011
  3. Roberto TyleyAug 4, 2011
  4. Sverre RabbelierAug 4, 2011
  5. Junio C HamanoAug 4, 2011
  6. Tolerate zlib deflation with window size < 32Kbroberto.tyley@gmail.com, Aug 7, 2011
  7. Junio C HamanoAug 8, 2011
  8. Junio C HamanoAug 8, 2011

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.