Skip to content

Commit 723bdf4

Browse files
committed
patch_parse: check if advancing over header newline succeeds
While parsing patch header lines, we iterate over each line and check if the line has trailing garbage. What we do not check though is that the line is actually a line ending with a trailing newline. Fix this by checking the return code of `parse_advance_expected_str`.
1 parent 8d45244 commit 723bdf4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/patch_parse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ static int parse_header_git(
444444
goto done;
445445

446446
parse_advance_ws(ctx);
447-
parse_advance_expected_str(ctx, "\n");
448447

449-
if (ctx->line_len > 0) {
448+
if (parse_advance_expected_str(ctx, "\n") < 0 ||
449+
ctx->line_len > 0) {
450450
error = parse_err("trailing data at line %"PRIuZ, ctx->line_num);
451451
goto done;
452452
}

0 commit comments

Comments
 (0)