Attached is a patch written some time ago to make the REST command grok large files on LFS-capable platforms by using apr_strtoff() instead of strtol().

It's untested, mostly because I didn't have a test server handy at the moment. Thought I should submit the patch before I lost it in the twisty maze of svn trees though.

/Nikke
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se      |     [EMAIL PROTECTED]
---------------------------------------------------------------------------
 Fiddle: Friction of a horse's tail on cat's entrails.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Index: modules/ftp/ftp_commands.c
===================================================================
--- modules/ftp/ftp_commands.c  (revision 533227)
+++ modules/ftp/ftp_commands.c  (working copy)
@@ -1784,33 +1784,18 @@
 static int ftp_cmd_rest(request_rec *r, const char *arg)
 {
     ftp_connection *fc = ftp_get_module_config(r->request_config);
-    conn_rec *c = r->connection;
     char *endp;
+    apr_status_t rv;
 
-    /* XXX: shortcoming, cannot restart > ~2GB.  Must be solved in 
-     * APR, or we need to use 
-     *  int len;
-     *  res = sscanf(arg,"%"APR_OFF_T_FMT"%n", &fc->restart_point, &len);
-     *  end = arg + len;
-     * and test that res == 2. Dunno how portable or safe this gross
-     * hack would be in real life.
-     */
-    fc->restart_point = strtol(arg, &endp, 10);
-    if (((*arg == '\0') || (*endp != '\0')) || fc->restart_point < 0) {
-        fc->response_notes = apr_pstrdup(r->pool, "REST requires a an "
-                                         "integer value greater than zero");
+    rv = apr_strtoff(&(fc->restart_point), arg, &endp, 10);
+    if (rv != APR_SUCCESS || ((*arg == '\0') || (*endp != '\0')) || 
+            fc->restart_point < 0) 
+    {
+        fc->response_notes = apr_pstrdup(r->pool, "REST requires a "
+                                         "non-negative integer value");
         return FTP_REPLY_SYNTAX_ERROR;
     }
 
-    /* Check overflow condition */
-    if (fc->restart_point == LONG_MAX) {
-        ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, 
-                     c->base_server,
-                     "Client attempted an invalid restart point");
-        /* XXX: possible overflow, continue gracefully?  Many other FTP
-         * client do not check overflow conditions in the REST command.
-         */
-    }
     fc->response_notes = apr_psprintf(r->pool, "Restarting at %" APR_OFF_T_FMT
                                       ". Send STORE or RETRIEVE to initiate "
                                       "transfer.", fc->restart_point);

Reply via email to