Commit b5ba7af2 by Patrick Steinhardt

smart_pkt: fix "ng" parser accepting non-space character

When parsing "ng" packets, we blindly assume that the character
immediately following the "ng" prefix is a space and skip it. As the
calling function doesn't make sure that this is the case, we can thus
end up blindly accepting an invalid packet line.

Fix the issue by using `git__prefixncmp`, checking whether the line
starts with "ng ".
parent a9f1ca09
......@@ -306,9 +306,9 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
eol = line + len;
if (len < 3)
if (git__prefixncmp(line, len, "ng "))
goto out_err;
line += 3; /* skip "ng " */
line += 3;
if (!(ptr = memchr(line, ' ', eol - line)))
goto out_err;
......
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