You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/11/15 13:11:58 UTC

svn commit: r1035243 - in /subversion/trunk/subversion: libsvn_client/patch.c svn/patch-cmd.c tests/cmdline/input_validation_tests.py

Author: stsp
Date: Mon Nov 15 12:11:57 2010
New Revision: 1035243

URL: http://svn.apache.org/viewvc?rev=1035243&view=rev
Log:
As part of issue #3620, fix a user-triggerable assertion in svn patch.

* subversion/tests/cmdline/input_validation_tests.py
  (invalid_patch_targets, test_list): New test.

* subversion/svn/patch-cmd.c,
  subversion/libsvn_client/patch.c
  (svn_cl__patch, svn_client_patch): Verify that the working copy target
   path is not a URL.

Modified:
    subversion/trunk/subversion/libsvn_client/patch.c
    subversion/trunk/subversion/svn/patch-cmd.c
    subversion/trunk/subversion/tests/cmdline/input_validation_tests.py

Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=1035243&r1=1035242&r2=1035243&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Mon Nov 15 12:11:57 2010
@@ -2753,6 +2753,12 @@ svn_client_patch(const char *patch_abspa
     return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
                             _("strip count must be positive"));
 
+  if (svn_path_is_url(local_abspath))
+    return svn_error_return(svn_error_createf(SVN_ERR_ILLEGAL_TARGET,
+                                              NULL,
+                                              _("'%s' is not a local path"),
+                                              local_abspath));
+
   baton.patch_abspath = patch_abspath;
   baton.abs_wc_path = local_abspath;
   baton.dry_run = dry_run;

Modified: subversion/trunk/subversion/svn/patch-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/patch-cmd.c?rev=1035243&r1=1035242&r2=1035243&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/patch-cmd.c (original)
+++ subversion/trunk/subversion/svn/patch-cmd.c Mon Nov 15 12:11:57 2010
@@ -52,6 +52,7 @@ svn_cl__patch(apr_getopt_t *os,
   apr_array_header_t *targets;
   const char *abs_patch_path;
   const char *abs_target_path;
+  const char *target_path;
 
   opt_state = ((svn_cl__cmd_baton_t *)baton)->opt_state;
   ctx = ((svn_cl__cmd_baton_t *)baton)->ctx;
@@ -68,9 +69,14 @@ svn_cl__patch(apr_getopt_t *os,
 
   svn_opt_push_implicit_dot_target(targets, pool);
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
-  SVN_ERR(svn_dirent_get_absolute(&abs_target_path,
-                                  APR_ARRAY_IDX(targets, 0, const char *),
-                                  pool));
+
+  target_path = APR_ARRAY_IDX(targets, 0, const char *);
+  if (svn_path_is_url(target_path))
+    return svn_error_return(svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
+                                              NULL,
+                                              _("'%s' is not a local path"),
+                                              target_path));
+  SVN_ERR(svn_dirent_get_absolute(&abs_target_path, target_path, pool));
 
   SVN_ERR(svn_client_patch(abs_patch_path, abs_target_path,
                            opt_state->dry_run, opt_state->strip,

Modified: subversion/trunk/subversion/tests/cmdline/input_validation_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/input_validation_tests.py?rev=1035243&r1=1035242&r2=1035243&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/input_validation_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/input_validation_tests.py Mon Nov 15 12:11:57 2010
@@ -215,6 +215,13 @@ def invalid_status_targets(sbox):
     run_and_verify_svn_in_wc(sbox, "svn:.*is not a local path", 'status',
                              target)
 
+def invalid_patch_targets(sbox):
+  "non-working copy paths for 'patch'"
+  sbox.build(read_only=True)
+  for (target1, target2) in [("foo.diff", "^/"), ("^/", "^/")]:
+    run_and_verify_svn_in_wc(sbox, "svn:.*is not a local path", 'patch',
+                             target1, target2)
+
 ########################################################################
 # Run the tests
 
@@ -239,6 +246,7 @@ test_list = [ None,
               invalid_lock_targets,
               invalid_unlock_targets,
               invalid_status_targets,
+              invalid_patch_targets,
              ]
 
 if __name__ == '__main__':