]> git.ipfire.org Git - thirdparty/git.git/commitdiff
packfile: fix off-by-one error in decoding logic
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Jan 2022 20:11:42 +0000 (12:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Jan 2022 20:14:49 +0000 (12:14 -0800)
shift count being exactly at 7-bit smaller than the long is OK; on
32-bit architecture, shift count starts at 4 and goes through 11, 18
and 25, at which point the guard triggers one iteration too early.

Reported-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
packfile.c

index d3820c780b46605e11817d479880a99959a2bddf..667e21ce979881c2695e512ec539cac24af49158 100644 (file)
@@ -1067,7 +1067,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
        size = c & 15;
        shift = 4;
        while (c & 0x80) {
-               if (len <= used || (bitsizeof(long) - 7) <= shift) {
+               if (len <= used || (bitsizeof(long) - 7) < shift) {
                        error("bad object header");
                        size = used = 0;
                        break;