]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable: reject 0 object_id_len
authorHan-Wen Nienhuys <hanwen@google.com>
Mon, 21 Feb 2022 18:46:05 +0000 (18:46 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Feb 2022 21:36:26 +0000 (13:36 -0800)
The spec says 2 <= object_id_len <= 31. We are lenient and allow 1,
but we forbid 0, so we can be sure that we never read a 0-length key.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/reader.c

index 00906e7a2de218085eaec3c8488365cb2da0a0a8..54b4025105cfd6dc53821d366a1dd20bc8d11004 100644 (file)
@@ -155,6 +155,11 @@ static int parse_footer(struct reftable_reader *r, uint8_t *footer,
        r->log_offsets.is_present = (first_block_typ == BLOCK_TYPE_LOG ||
                                     r->log_offsets.offset > 0);
        r->obj_offsets.is_present = r->obj_offsets.offset > 0;
+       if (r->obj_offsets.is_present && !r->object_id_len) {
+               err = REFTABLE_FORMAT_ERROR;
+               goto done;
+       }
+
        err = 0;
 done:
        return err;