[PATCH v7 02/10] pkt-line: fix packet_read_line() to handle len < 0 errors
- From
Ben Peart <peartben@gmail.com>
- Date
- May 5, 2017, 15:27 UTC
- Message-ID
- <20170505152802.6724-3-benpeart@microsoft.com>
- In-Reply-To
- <20170505152802.6724-1-benpeart@microsoft.com>
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> --- pkt-line.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pkt-line.c b/pkt-line.c index d4b6bfe076..6f05b1a4a8 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)
-- 2.12.2.gvfs.2.20.g3624a68d62.dirty