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

1 review trailer.

[PATCH 12/16] vcs-svn: verify that deltas consume all inline data

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

From: Jonathan Nieder <redacted>

By constraining the format of deltas, we can more easily detect
corruption and other breakage.

Requiring deltas not to provide unconsumed data also opens the
possibility of ignoring the declared amount of new data and simply
streaming the data as needed to fulfill copyfrom_data requests.

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 |    2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/t/t9011-svn-da.sh b/t/t9011-svn-da.sh
index c6dbb21..7f422ca 100755
--- a/t/t9011-svn-da.sh
+++ b/t/t9011-svn-da.sh
@@ -123,11 +123,10 @@ test_expect_success 'preimage view: reject truncated preimage' '
 	test_must_fail test-svn-fe -d preimage clear.longread 9
 '
 
-test_expect_success 'inline data' '
+test_expect_success 'forbid unconsumed inline data' '
 	printf "SVNQ%b%s%b%s" "QQQQ\003" "bar" "QQQQ\001" "x" |
 		q_to_nul >inline.clear &&
-	test-svn-fe -d preimage inline.clear 18 >actual &&
-	test_cmp empty actual
+	test_must_fail test-svn-fe -d preimage inline.clear 18 >actual
 '
 
 test_expect_success 'reject truncated inline data' '
diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c
index 118e8c6..6b505dc 100644
--- a/vcs-svn/svndiff.c
+++ b/vcs-svn/svndiff.c
@@ -208,6 +208,8 @@ static int apply_window_in_core(struct window *ctx)
 	     )
 		if (execute_one_instruction(ctx, &instructions, &data_pos))
 			return -1;
+	if (data_pos != ctx->data.len)
+		return error("invalid delta: does not copy all inline data");
 	return 0;
 }
 
-- 
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