[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1084138 - in /subversion/trunk/subversion: libsvn_diff/parse-diff.c tests/libsvn_diff/parse-diff-test.c

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Sun, 26 Mar 2000 10:27:38 +0200

You can declare VALID_HEADER_FILE in the do{} loop's scope. (I spotted
this because the double initialization stood out.)

dannas_at_apache.org wrote on Tue, Mar 22, 2011 at 11:19:44 -0000:
> Author: dannas
> Date: Tue Mar 22 11:19:44 2011
> New Revision: 1084138
>
> URL: http://svn.apache.org/viewvc?rev=1084138&view=rev
> Log:
> Fix issue #3809 - 'svn patch' accepts invalid git diff headers.
>
> * subversion/libsvn_diff/parse-diff.c
> (svn_diff_parse_next_patch): Disallow non-header lines in the header.
>
> * subversion/tests/libsvn_diff/parse-diff-test.c
> (bad_git_diff_header): Remove sentence that says that the test is
> failing.
> (test_funcs): Remove XFAIL marker.
>
> Modified:
> subversion/trunk/subversion/libsvn_diff/parse-diff.c
> subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c
>
> Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=1084138&r1=1084137&r2=1084138&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
> +++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Tue Mar 22 11:19:44 2011
> @@ -1286,6 +1286,7 @@ svn_diff_parse_next_patch(svn_patch_t **
> {
> apr_off_t pos, last_line;
> svn_boolean_t eof;
> + svn_boolean_t valid_header_line = FALSE;
> svn_boolean_t line_after_tree_header_read = FALSE;
> apr_pool_t *iterpool;
> enum parse_state state = state_start;
> @@ -1323,6 +1324,8 @@ svn_diff_parse_next_patch(svn_patch_t **
> iterpool));
> }
>
> + valid_header_line = FALSE;
> +
> /* Run the state machine. */
> for (i = 0; i < (sizeof(transitions) / sizeof(transitions[0])); i++)
> {
> @@ -1332,6 +1335,7 @@ svn_diff_parse_next_patch(svn_patch_t **
> {
> SVN_ERR(transitions[i].fn(&state, line->data, *patch,
> result_pool, iterpool));
> + valid_header_line = TRUE;
> break;
> }
> }
> @@ -1352,7 +1356,19 @@ svn_diff_parse_next_patch(svn_patch_t **
> break;
> }
> else if (state == state_git_tree_seen)
> - line_after_tree_header_read = TRUE;
> + {
> + line_after_tree_header_read = TRUE;
> + }
> + else if (! valid_header_line && state != state_start)
> + {
> + /* We've encountered an invalid diff header.
> + *
> + * Rewind to the start of the line just read - it may be a new
> + * header that begins there. */
> + SVN_ERR(svn_io_file_seek(patch_file->apr_file, APR_SET, &last_line,
> + scratch_pool));
> + state = state_start;
> + }
>
> }
> while (! eof);
>
> Modified: subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c?rev=1084138&r1=1084137&r2=1084138&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c (original)
> +++ subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c Tue Mar 22 11:19:44 2011
> @@ -120,9 +120,8 @@ static const char *git_tree_and_text_uni
> "" NL;
>
> /* Only the last git diff header is valid. The other ones either misses a
> - * path element or has noise between lines that must be continous. The
> - * test test_bad_git_diff_headers currently fails because the headers with
> - * random noise are tolerated. See issue #3809. */
> + * path element or has noise between lines that must be continous. See
> + * issue #3809. */
> static const char *bad_git_diff_header =
> "Index: iota.copied" NL
> "===================================================================" NL
> @@ -925,7 +924,7 @@ struct svn_test_descriptor_t test_funcs[
> "test git unidiff parsing"),
> SVN_TEST_PASS2(test_parse_git_tree_and_text_diff,
> "test git unidiff parsing of tree and text changes"),
> - SVN_TEST_XFAIL2(test_bad_git_diff_headers,
> + SVN_TEST_PASS2(test_bad_git_diff_headers,
> "test badly formatted git diff headers"),
> SVN_TEST_PASS2(test_parse_property_diff,
> "test property unidiff parsing"),
>
>
Received on 2011-03-26 08:59:44 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.