summaryrefslogtreecommitdiff
path: root/pkt-line.c
diff options
context:
space:
mode:
authorBen Peart <peartben@gmail.com>2017-05-05 15:27:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-08 01:57:26 (GMT)
commit974b50c5565107e1e3209176682ee6f6e420bd2b (patch)
tree39fb555270c308253f9b5ebc61abda4f13f2ac33 /pkt-line.c
parent070e5f72d9d6f0056895bd3222e75f8075ed4c0e (diff)
downloadgit-974b50c5565107e1e3209176682ee6f6e420bd2b.zip
git-974b50c5565107e1e3209176682ee6f6e420bd2b.tar.gz
git-974b50c5565107e1e3209176682ee6f6e420bd2b.tar.bz2
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>
Diffstat (limited to 'pkt-line.c')
-rw-r--r--pkt-line.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkt-line.c b/pkt-line.c
index d4b6bfe..6f05b1a 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -315,7 +315,7 @@ static char *packet_read_line_generic(int fd,
PACKET_READ_CHOMP_NEWLINE);
if (dst_len)
*dst_len = len;
- return len ? packet_buffer : NULL;
+ return (len > 0) ? packet_buffer : NULL;
}
char *packet_read_line(int fd, int *len_p)