Skip to content

Commit 974b50c

Browse files
benpeartgitster
authored andcommitted
pkt-line: fix packet_read_line() to handle len < 0 errors
Update packet_read_line() to test for len > 0 to avoid potential bug if read functions return lengths less than zero to indicate errors. Signed-off-by: Ben Peart <benpeart@microsoft.com> Found/Fixed-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 070e5f7 commit 974b50c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pkt-line.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static char *packet_read_line_generic(int fd,
315315
PACKET_READ_CHOMP_NEWLINE);
316316
if (dst_len)
317317
*dst_len = len;
318-
return len ? packet_buffer : NULL;
318+
return (len > 0) ? packet_buffer : NULL;
319319
}
320320

321321
char *packet_read_line(int fd, int *len_p)

0 commit comments

Comments
 (0)