Hi,
I found a little bug in parsing a change revision: If the number,
given to the --change argument, starts with a double minus or with
`-r-`, the command aborts. This patch fixes this bug.
Steps to reproduce:
$ svn diff https://svn.apache.org/repos/asf -c --123
svn: E235000: In file '..\..\..\subversion\libsvn_client\ra.c' line
692: assertion failed (SVN_IS_VALID_REVNUM(start_revnum))
Or...
$ svn diff https://svn.apache.org/repos/asf -c -r-123
svn: E235000: In file '..\..\..\subversion\libsvn_client\ra.c' line
692: assertion failed (SVN_IS_VALID_REVNUM(start_revnum))
The same would happen if the svn diff command is invoked from a
working copy, without URL.
[[[
Fix bug: check the change argument for a double minus at the start.
If changeno is negative and is_negative is TRUE, raise
SVN_ERR_CL_ARG_PARSING_ERROR, because string with a double minus is
not a valid number.
* subversion/svn/svn.c
(sub_main): If changeno is negative and is_negative is TRUE, raise
SVN_ERR_CL_ARG_PARSING_ERROR.
* subversion/tests/cmdline/diff_tests.py
(diff_invalid_change_arg): New test.
(test_list): Run new test.
]]]
Best regards,
Timofei Zhakov
Index: C:/tima/svn-trunk/subversion/svn/svn.c
===================================================================
--- C:/tima/svn-trunk/subversion/svn/svn.c (revision 1917823)
+++ C:/tima/svn-trunk/subversion/svn/svn.c (working copy)
@@ -2391,6 +2391,14 @@ sub_main(int *exit_code, int argc, const char *arg
_("There is no change 0"));
}
+ /* The revision number cannot contain a double minus */
+ if (changeno < 0 && is_negative)
+ {
+ return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Non-numeric change argument (%s)
"
+ "given to -c"), change_str);
+ }
+
if (is_negative)
changeno = -changeno;
Index: C:/tima/svn-trunk/subversion/tests/cmdline/diff_tests.py
===================================================================
--- C:/tima/svn-trunk/subversion/tests/cmdline/diff_tests.py (revision
1917823)
+++ C:/tima/svn-trunk/subversion/tests/cmdline/diff_tests.py (working copy)
@@ -5329,7 +5329,21 @@ def diff_nonexistent_in_wc(sbox):
svntest.actions.run_and_verify_svn(expected_output_head_base, [],
'diff', '-r', '1')
+def diff_invalid_change_arg(sbox):
+ "invalid change argument"
+ sbox.build()
+
+ svntest.actions.run_and_verify_svn(
+ None,
+ (r'.*svn: E205000: Non-numeric change argument \(--1\) given to -c'),
+ 'diff', sbox.wc_dir, '-c', '--1')
+
+ svntest.actions.run_and_verify_svn(
+ None,
+ (r'.*svn: E205000: Non-numeric change argument \(-r-1\) given to -c'),
+ 'diff', sbox.wc_dir, '-c', '-r-1')
+
########################################################################
#Run the tests
@@ -5431,6 +5445,7 @@ test_list = [ None,
diff_file_replaced_by_symlink,
diff_git_format_copy,
diff_nonexistent_in_wc,
+ diff_invalid_change_arg,
]
if __name__ == '__main__':