diff options
author | Patrick Steinhardt <ps@pks.im> | 2018-08-09 11:36:44 +0300 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-10-03 17:06:48 +0300 |
commit | 4a5804c983317100eed509537edc32d69c8d7aa2 (patch) | |
tree | ea9b5b563f0e69b53bd4abf6942babaa03bae181 /src/transports/smart_pkt.c | |
parent | 365d2720c1a5fc89f03fd85265c8b45195c7e4a8 (diff) |
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.
Diffstat (limited to 'src/transports/smart_pkt.c')
-rw-r--r-- | src/transports/smart_pkt.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/transports/smart_pkt.c b/src/transports/smart_pkt.c index 00798c396..7c5a3f2b6 100644 --- a/src/transports/smart_pkt.c +++ b/src/transports/smart_pkt.c @@ -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); |