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/09/09 19:18:36 UTC

svn commit: r995501 - /subversion/trunk/subversion/svnserve/main.c

Author: stsp
Date: Thu Sep  9 17:18:36 2010
New Revision: 995501

URL: http://svn.apache.org/viewvc?rev=995501&view=rev
Log:
* subversion/svnserve/main.c
  (): Include svn_string.h and private/svn_dep_compat.h.
  (main): Parse the --listen-port argument with svn_cstring_strtoui64() instead
   of atoi(). Make sure the argument parses correctly as a 16 bit unsigned
   integer. Previously, any argument was accepted, e.g. --listen-port "abc"
   actually worked (PORT ended up being zero, so the OS assigned a random port).

Modified:
    subversion/trunk/subversion/svnserve/main.c

Modified: subversion/trunk/subversion/svnserve/main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/main.c?rev=995501&r1=995500&r2=995501&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/main.c (original)
+++ subversion/trunk/subversion/svnserve/main.c Thu Sep  9 17:18:36 2010
@@ -44,11 +44,13 @@
 #include "svn_path.h"
 #include "svn_opt.h"
 #include "svn_repos.h"
+#include "svn_string.h"
 #include "svn_fs.h"
 #include "svn_version.h"
 #include "svn_io.h"
 
 #include "svn_private_config.h"
+#include "private/svn_dep_compat.h"
 #include "winservice.h"
 
 #ifdef HAVE_UNISTD_H
@@ -473,7 +475,17 @@ int main(int argc, const char *argv[])
           break;
 
         case SVNSERVE_OPT_LISTEN_PORT:
-          port = atoi(arg);
+          {
+            apr_uint64_t val;
+
+            err = svn_cstring_strtoui64(&val, arg, 0, APR_UINT16_MAX, 10);
+            if (err)
+              return svn_cmdline_handle_exit_error(
+                       svn_error_createf(SVN_ERR_INCORRECT_PARAMS, err,
+                                         _("Invalid port '%s'"), arg),
+                       pool, "svnserve: ");
+            port = (apr_uint16_t)val;
+          }
           break;
 
         case SVNSERVE_OPT_LISTEN_HOST: