Thread (77 messages) 77 messages, 4 authors, 2016-06-15

[PATCH 07/11] vcs-svn: Check declared number of output bytes

flat view
STALE3772d

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:49:46
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help