Skip to content

Commit b5ba7af

Browse files
committed
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 ".
1 parent a9f1ca0 commit b5ba7af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/transports/smart_pkt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
306306

307307
eol = line + len;
308308

309-
if (len < 3)
309+
if (git__prefixncmp(line, len, "ng "))
310310
goto out_err;
311-
line += 3; /* skip "ng " */
311+
line += 3;
312312

313313
if (!(ptr = memchr(line, ' ', eol - line)))
314314
goto out_err;

0 commit comments

Comments
 (0)