Author: svn-role
Date: Sat Jul  6 04:00:03 2024
New Revision: 1918956

URL: http://svn.apache.org/viewvc?rev=1918956&view=rev
Log:
Merge the r1917864 group from trunk:

 * r1917864, r1917944
   Fix cmdline parsing bugs in --change (-c) argument
   Justification:
     Syntax error in cmdline arg should not cause assertion failure
   Votes:
     +1: hartmannathan, astieger, jamessan, rinrab

Modified:
    subversion/branches/1.14.x/   (props changed)
    subversion/branches/1.14.x/STATUS
    subversion/branches/1.14.x/subversion/svn/svn.c
    subversion/branches/1.14.x/subversion/tests/cmdline/diff_tests.py

Propchange: subversion/branches/1.14.x/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1917864,1917944

Modified: subversion/branches/1.14.x/STATUS
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.14.x/STATUS?rev=1918956&r1=1918955&r2=1918956&view=diff
==============================================================================
--- subversion/branches/1.14.x/STATUS (original)
+++ subversion/branches/1.14.x/STATUS Sat Jul  6 04:00:03 2024
@@ -28,13 +28,6 @@ Veto-blocked changes:
 Approved changes:
 =================
 
- * r1917864, r1917944
-   Fix cmdline parsing bugs in --change (-c) argument
-   Justification:
-     Syntax error in cmdline arg should not cause assertion failure
-   Votes:
-     +1: hartmannathan, astieger, jamessan, rinrab
-
  * r1917946
    Convert path to local style in error message from diff API
    Justification:
@@ -55,4 +48,3 @@ Approved changes:
      Follow SVN's iterpool conventions
    Votes:
      +1: hartmannathan, jamessan, rinrab
-

Modified: subversion/branches/1.14.x/subversion/svn/svn.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/svn/svn.c?rev=1918956&r1=1918955&r2=1918956&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/svn/svn.c (original)
+++ subversion/branches/1.14.x/subversion/svn/svn.c Sat Jul  6 04:00:03 2024
@@ -2194,6 +2194,15 @@ sub_main(int *exit_code, int argc, const
                   while (*s == 'r')
                     s++;
                   changeno_end = strtol(s, &end, 10);
+
+                  if (changeno_end < 0)
+                    {
+                      return svn_error_createf(
+                        SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                        _("Negative number in range (%s)"
+                          " not supported with -c"),
+                        change_str);
+                    }
                 }
               if (end == change_str || *end != '\0')
                 {
@@ -2202,12 +2211,20 @@ sub_main(int *exit_code, int argc, const
                                              "given to -c"), change_str);
                 }
 
-              if (changeno == 0)
+              if (changeno == 0 || changeno_end == 0)
                 {
                   return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                                           _("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;
 

Modified: subversion/branches/1.14.x/subversion/tests/cmdline/diff_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/tests/cmdline/diff_tests.py?rev=1918956&r1=1918955&r2=1918956&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/branches/1.14.x/subversion/tests/cmdline/diff_tests.py Sat Jul  
6 04:00:03 2024
@@ -5329,6 +5329,41 @@ 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')
+
+  svntest.actions.run_and_verify_svn(
+    None,
+    (r'.*svn: E205000: Negative number in range \(1--3\) not supported with 
-c'),
+    'diff', sbox.wc_dir, '-c', '1--3')
+
+  # 'r' is not a number
+  svntest.actions.run_and_verify_svn(
+    None,
+    (r'.*svn: E205000: Non-numeric change argument \(r1--r3\) given to -c'),
+    'diff', sbox.wc_dir, '-c', 'r1--r3')
+
+  svntest.actions.run_and_verify_svn(
+    None,
+    (r'.*svn: E205000: Negative number in range \(r1-r-3\) not supported with 
-c'),
+    'diff', sbox.wc_dir, '-c', 'r1-r-3')
+
+  svntest.actions.run_and_verify_svn(
+    None,
+    (r'.*svn: E205000: There is no change 0'),
+    'diff', sbox.wc_dir, '-c', '1-0')
 
 ########################################################################
 #Run the tests
@@ -5431,6 +5466,7 @@ test_list = [ None,
               diff_file_replaced_by_symlink,
               diff_git_format_copy,
               diff_nonexistent_in_wc,
+              diff_invalid_change_arg,
               ]
 
 if __name__ == '__main__':


Reply via email to