]> git.ipfire.org Git - thirdparty/git.git/commit - trailer.c
trailer: use size_t for iterating trailer list
authorJeff King <peff@peff.net>
Thu, 23 Aug 2018 00:45:44 +0000 (20:45 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Aug 2018 17:08:51 +0000 (10:08 -0700)
commita3b636e21574e6cff1494e0a84644e06201ddb8d
treeb7587477affaebe30612e6c7667d4fe7e1e30be1
parent0d2db00e24ee2df4459151c5ba6de9306e30e727
trailer: use size_t for iterating trailer list

We store the length of the trailers list in a size_t. So on
a 64-bit system with a 32-bit int, in the unlikely case that
we manage to actually allocate a list with 2^31 entries,
we'd loop forever trying to iterate over it (our "int" would
wrap to negative before exceeding info->trailer_nr).

This probably doesn't matter in practice. Each entry is at
least a pointer plus a non-empty string, so even without
malloc overhead or the memory to hold the original string
we're parsing from, you'd need to allocate tens of
gigabytes. But it's easy enough to do it right.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
trailer.c