diff options
author | Jon Simons <jon@jonsimons.org> | 2018-02-08 13:47:50 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-08 12:37:40 -0800 |
commit | bb1356dc643e1488ccc1924ab674f6cbbe615f74 (patch) | |
tree | 88bf6c08ac171e299567bd53df1f2820d577c691 /send-pack.c | |
parent | bc9d4dc5b07c05c7b26a4e781b7538db7c775fc3 (diff) | |
download | git-bb1356dc643e1488ccc1924ab674f6cbbe615f74.tar.gz |
always check for NULL return from packet_read_line()js/packet-read-line-check-null
The packet_read_line() function will die if it sees any
protocol or socket errors. But it will return NULL for a
flush packet; some callers which are not expecting this may
dereference NULL if they get an unexpected flush. This would
involve the other side breaking protocol, but we should
flag the error rather than segfault.
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'send-pack.c')
-rw-r--r-- | send-pack.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/send-pack.c b/send-pack.c index 2112d3b27a..8d9190f5e7 100644 --- a/send-pack.c +++ b/send-pack.c @@ -137,6 +137,8 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc static int receive_unpack_status(int in) { const char *line = packet_read_line(in, NULL); + if (!line) + return error(_("unexpected flush packet while reading remote unpack status")); if (!skip_prefix(line, "unpack ", &line)) return error(_("unable to parse remote unpack status: %s"), line); if (strcmp(line, "ok")) |