Message ID | 4c1a19fc4aef2742e2733b804221186aa164f721.1645106124.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | reftable: avoid reading and writing empty keys | expand |
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: Han-Wen Nienhuys <hanwen@google.com> > > The spec says 2 <= object_id_len <= 31. We are lenient and allow 1, > but we forbid 0, so we can we can be sure that we never read a s/we can we can/we can/; > 0-length key. > > Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> > --- > reftable/reader.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/reftable/reader.c b/reftable/reader.c > index 00906e7a2de..54b4025105c 100644 > --- a/reftable/reader.c > +++ b/reftable/reader.c > @@ -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;
diff --git a/reftable/reader.c b/reftable/reader.c index 00906e7a2de..54b4025105c 100644 --- a/reftable/reader.c +++ b/reftable/reader.c @@ -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;