From: Jonathan Nieder Date: Wed, 13 Oct 2010 09:41:15 GMT Subject: [PATCH 07/11] vcs-svn: Check declared number of output bytes Message-ID: <20101013094115.GH32608@burratino> In-Reply-To: <20101013091714.GA32608@burratino> Check that the declared output size for each window is correct, and reserve that amount of space in the output buffer in advance. Signed-off-by: Jonathan Nieder --- vcs-svn/svndiff.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c index ac776e0..c03cd7e 100644 --- a/vcs-svn/svndiff.c +++ b/vcs-svn/svndiff.c @@ -220,10 +220,15 @@ static int apply_one_window(struct line_buffer *delta, off_t *delta_len, rv = error("Cannot read delta: %s", strerror(errno)); goto done; } + strbuf_grow(&ctx.out, out_len); if (apply_window_in_core(&ctx) || write_strbuf(&ctx.out, out)) { rv = -1; goto done; } + if (ctx.out.len != out_len) { + rv = error("Invalid delta: incorrect postimage length"); + goto done; + } done: strbuf_release(&ctx.data); strbuf_release(&ctx.instructions); -- 1.7.2.3