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>
This commit is contained in:

committed by
Junio C Hamano

parent
0d2db00e24
commit
a3b636e215
@ -225,7 +225,7 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
|
||||
int ignore_footer)
|
||||
{
|
||||
struct trailer_info info;
|
||||
int i;
|
||||
size_t i;
|
||||
int found_sob = 0, found_sob_last = 0;
|
||||
|
||||
trailer_info_get(&info, sb->buf);
|
||||
|
Reference in New Issue
Block a user