Skip to content

Commit f2214de

Browse files
bk2204gitster
authored andcommitted
builtin/receive-pack: fix incorrect pointer arithmetic
If we had already processed the last newline in a push certificate, we would end up subtracting NULL from the end-of-certificate pointer when computing the length of the line. This would have resulted in an absurdly large length, and possibly a buffer overflow. Instead, subtract the beginning-of-certificate pointer from the end-of-certificate pointer, which is what's expected. Note that this situation should never occur, since not only do we require the certificate to be newline terminated, but the signature will only be read from the beginning of a line. Nevertheless, it seems prudent to correct it. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6f5ef44 commit f2214de

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ static void queue_commands_from_cert(struct command **tail,
11271127

11281128
while (boc < eoc) {
11291129
const char *eol = memchr(boc, '\n', eoc - boc);
1130-
tail = queue_command(tail, boc, eol ? eol - boc : eoc - eol);
1130+
tail = queue_command(tail, boc, eol ? eol - boc : eoc - boc);
11311131
boc = eol ? eol + 1 : eoc;
11321132
}
11331133
}

0 commit comments

Comments
 (0)