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

PATCH: Reject a revision range rather than ignoring part of it

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2003-11-24 02:29:06 CET

I assume we want this better input validation. Any comments, or is it OK to commit it?

[[[
Subcommands that cannot use a revision range will now reject a revision range
rather than ignoring part of it.

* subversion/clients/cmdline/cat-cmd.c
  (svn_cl__cat): Move the check for a revision range out to "main.c",
    because many subcommands should check this.

* subversion/clients/cmdline/main.c
  (main): Disallow a revision range except for the few commands that can
    accept one.
]]]

- Julian

Subcommands that cannot use a revision range will now reject a revision range
rather than ignoring part of it.

* subversion/clients/cmdline/cat-cmd.c
  (svn_cl__cat): Move the check for a revision range out to "main.c",
    because many subcommands should check this.

* subversion/clients/cmdline/main.c
  (main): Disallow a revision range except for the few commands that can
    accept one.

Index: subversion/clients/cmdline/cat-cmd.c
===================================================================
--- subversion/clients/cmdline/cat-cmd.c (revision 7831)
+++ subversion/clients/cmdline/cat-cmd.c (working copy)
@@ -44,10 +44,6 @@ svn_cl__cat (apr_getopt_t *os,
   svn_stream_t *out;
   apr_pool_t *subpool = svn_pool_create (pool);
 
- if (opt_state->end_revision.kind != svn_opt_revision_unspecified)
- return svn_error_createf (SVN_ERR_CLIENT_REVISION_RANGE, NULL,
- "cat only accepts a single revision");
-
   SVN_ERR (svn_opt_args_to_target_array (&targets, os,
                                          opt_state->targets,
                                          &(opt_state->start_revision),
Index: subversion/clients/cmdline/main.c
===================================================================
--- subversion/clients/cmdline/main.c (revision 7831)
+++ subversion/clients/cmdline/main.c (working copy)
@@ -1071,6 +1071,24 @@ main (int argc, const char * const *argv
         }
     }
 
+ /* Only a few commands can accept a revision range; the rest can take at
+ most one revision number. */
+ if (subcommand->cmd_func != svn_cl__blame
+ && subcommand->cmd_func != svn_cl__diff
+ && subcommand->cmd_func != svn_cl__log
+ && subcommand->cmd_func != svn_cl__merge)
+ {
+ if (opt_state.end_revision.kind != svn_opt_revision_unspecified)
+ {
+ svn_handle_error
+ (svn_error_create (SVN_ERR_CLIENT_REVISION_RANGE, NULL,
+ "this command only accepts a single revision"),
+ stderr, FALSE);
+ svn_pool_destroy (pool);
+ return EXIT_FAILURE;
+ }
+ }
+
   /* Create a client context object. */
   command_baton.opt_state = &opt_state;
   command_baton.ctx = &ctx;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Nov 24 02:26:55 2003

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