Commit a7e87dd5 by Patrick Steinhardt

smart_pkt: honor line length when determining packet type

When we parse the packet type of an incoming packet line, we do not
verify that we don't overflow the provided line buffer. Fix this by
using `git__prefixncmp` instead and passing in `len`. As we have
previously already verified that `len <= linelen`, we thus won't ever
overflow the provided buffer length.

(cherry picked from commit 4a5804c9)
parent 5d108c9a
......@@ -459,19 +459,19 @@ int git_pkt_parse_line(
ret = sideband_progress_pkt(head, line, len);
else if (*line == GIT_SIDE_BAND_ERROR)
ret = sideband_error_pkt(head, line, len);
else if (!git__prefixcmp(line, "ACK"))
else if (!git__prefixncmp(line, len, "ACK"))
ret = ack_pkt(head, line, len);
else if (!git__prefixcmp(line, "NAK"))
else if (!git__prefixncmp(line, len, "NAK"))
ret = nak_pkt(head);
else if (!git__prefixcmp(line, "ERR "))
else if (!git__prefixncmp(line, len, "ERR "))
ret = err_pkt(head, line, len);
else if (*line == '#')
ret = comment_pkt(head, line, len);
else if (!git__prefixcmp(line, "ok"))
else if (!git__prefixncmp(line, len, "ok"))
ret = ok_pkt(head, line, len);
else if (!git__prefixcmp(line, "ng"))
else if (!git__prefixncmp(line, len, "ng"))
ret = ng_pkt(head, line, len);
else if (!git__prefixcmp(line, "unpack"))
else if (!git__prefixncmp(line, len, "unpack"))
ret = unpack_pkt(head, line, len);
else
ret = ref_pkt(head, line, len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment