diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2011-03-26 00:15:10 -0500 |
---|---|---|
committer | Jonathan Nieder <jrnieder@gmail.com> | 2011-03-26 00:15:10 -0500 |
commit | e7d04ee147dcbe6af1fa1d2147466696e2be31bc (patch) | |
tree | ae39bba6d863b5185d08ce46106dff032ecee0e6 /t/t9010-svn-fe.sh | |
parent | 41b9dd9d4f2f32f8450af59c30f3a7a2fc5a8cc7 (diff) | |
download | git-e7d04ee147dcbe6af1fa1d2147466696e2be31bc.tar.gz |
vcs-svn: make reading of properties binary-safe
svn-fe errors out on revision 59151 of the ASF repository:
fatal: invalid dump: unexpected end of file
The proximate cause is a property with an embedded NUL character.
Previously such anomalies were ignored but commit c9d1c8ba
(2010-12-28) introduced a check strlen(val) == len to avoid reading
uninitialized data when a property list ends early and unfortunately
this test does not distinguish between "foo" followed by EOF and the
string "foo\0bar\0baz".
Fix it by using buffer_read_binary to read to a strbuf and checking
the actual length read. Most consumers of properties still use
C-style strings, so in practice an author or log message with embedded
NULs will be truncated, but a least this way svn-fe won't error out
(fixing the regression).
Reported-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Diffstat (limited to 't/t9010-svn-fe.sh')
-rwxr-xr-x | t/t9010-svn-fe.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh index 5a6a4b9b7a..5e2b123080 100755 --- a/t/t9010-svn-fe.sh +++ b/t/t9010-svn-fe.sh @@ -370,6 +370,33 @@ test_expect_failure 'change file mode but keep old content' ' test_cmp hello actual.target ' +test_expect_success 'NUL in property value' ' + reinit_git && + echo "commit message" >expect.message && + { + properties \ + unimportant "something with a NUL (Q)" \ + svn:log "commit message"&& + echo PROPS-END + } | + q_to_nul >props && + { + cat <<-\EOF && + SVN-fs-dump-format-version: 3 + + Revision-number: 1 + EOF + echo Prop-content-length: $(wc -c <props) && + echo Content-length: $(wc -c <props) && + echo && + cat props + } >nulprop.dump && + test-svn-fe nulprop.dump >stream && + git fast-import <stream && + git diff-tree --always -s --format=%s HEAD >actual.message && + test_cmp expect.message actual.message +' + test_expect_success 'change file mode and reiterate content' ' reinit_git && cat >expect <<-\EOF && |