summaryrefslogtreecommitdiff
path: root/src/patch_parse.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-03-20 09:35:23 +0100
committerPatrick Steinhardt <ps@pks.im>2017-03-21 15:48:16 +0100
commit723bdf48641736ece6a03032bae514ef28979dfe (patch)
treee65472ebc471cfa02936b5b3ac772e15ceb204ba /src/patch_parse.c
parent8d452448bb1d5da09966faad65bc5aa96ba3696c (diff)
downloadlibgit2-723bdf48641736ece6a03032bae514ef28979dfe.tar.gz
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`.
Diffstat (limited to 'src/patch_parse.c')
-rw-r--r--src/patch_parse.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/patch_parse.c b/src/patch_parse.c
index d993c0311..0a9edcd18 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -444,9 +444,9 @@ static int parse_header_git(
goto done;
parse_advance_ws(ctx);
- parse_advance_expected_str(ctx, "\n");
- if (ctx->line_len > 0) {
+ if (parse_advance_expected_str(ctx, "\n") < 0 ||
+ ctx->line_len > 0) {
error = parse_err("trailing data at line %"PRIuZ, ctx->line_num);
goto done;
}