Thread (67 messages) flat view 67 messages, 5 authors, 2016-06-15
STALE3732d REVIEWED: 1 (0M)

1 review trailer.

[PATCH 10/16] vcs-svn: read instructions from deltas

From: David Barr <hidden>
Date: 2016-06-15 22:50:48
Subsystem: the rest · Maintainer: Linus Torvalds

From: Jonathan Nieder <redacted>

Buffer the instruction section upon encountering it for later
interpretation.

An alternative design would involve parsing the instructions
at this point and buffering them in some processed form.  Using
the unprocessed form is simpler.

Signed-off-by: Jonathan Nieder <redacted>
Acked-by: Ramkumar Ramachandra <redacted>
Signed-off-by: David Barr <redacted>
---
 t/t9011-svn-da.sh |    5 +++++
 vcs-svn/svndiff.c |    6 +++++-
 2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/t/t9011-svn-da.sh b/t/t9011-svn-da.sh
index 4919fae..e909d92 100755
--- a/t/t9011-svn-da.sh
+++ b/t/t9011-svn-da.sh
@@ -135,4 +135,9 @@ test_expect_success 'reject truncated inline data' '
 	test_must_fail test-svn-fe -d preimage inline.trunc 10
 '
 
+test_expect_success 'reject truncated inline data (after instruction section)' '
+	printf "SVNQ%b%b%s" "QQ\001\001\003" "\0201" "b" | q_to_nul >insn.trunc &&
+	test_must_fail test-svn-fe -d preimage insn.trunc 11
+'
+
 test_done
diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c
index 74e0401..a2dd9b6 100644
--- a/vcs-svn/svndiff.c
+++ b/vcs-svn/svndiff.c
@@ -25,13 +25,15 @@
 #define VLI_BITS_PER_DIGIT 7
 
 struct window {
+	struct strbuf instructions;
 	struct strbuf data;
 };
 
-#define WINDOW_INIT	{ STRBUF_INIT }
+#define WINDOW_INIT	{ STRBUF_INIT, STRBUF_INIT }
 
 static void window_release(struct window *ctx)
 {
+	strbuf_release(&ctx->instructions);
 	strbuf_release(&ctx->data);
 }
 
@@ -126,6 +128,8 @@ static int apply_one_window(struct line_buffer *delta, off_t *delta_len)
 	    read_length(delta, &instructions_len, delta_len) ||
 	    read_length(delta, &data_len, delta_len))
 		goto error_out;
+	if (read_chunk(delta, delta_len, &ctx.instructions, instructions_len))
+		goto error_out;
 	if (instructions_len) {
 		error("What do you think I am?  A delta applier?");
 		goto error_out;
-- 
1.7.3.2.846.gf4b062
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help