Blob Blame History Raw
Backported from https://github.com/proftpd/proftpd/commit/51b9f9bb6c6dd8ea

Despite the ChangeLog entry that says 1.3.3g has pr_timer_usleep, it doesn't
actually have it so use pr_timer_sleep to sleep for 1 second instead of 250 ms.

--- src/main.c
+++ src/main.c
@@ -568,6 +568,7 @@ int pr_cmd_read(cmd_rec **res) {
   char buf[PR_DEFAULT_CMD_BUFSZ+1] = {'\0'};
   char *cp;
   size_t buflen;
+  unsigned int too_large_count = 0;
 
   if (res == NULL) {
     errno = EINVAL;
@@ -584,8 +585,16 @@ int pr_cmd_read(cmd_rec **res) {
 
       if (errno == E2BIG) {
         /* The client sent a too-long command which was ignored; give
-         * them another chance?
+         * them a few more chances, with minor delays?
          */
+
+        too_large_count++;
+        pr_timer_sleep(1);
+
+        if (too_large_count > 3) {
+          return -1;
+        }
+
         continue;
       }
 
--- src/netio.c
+++ src/netio.c
@@ -892,6 +892,7 @@ int pr_netio_read(pr_netio_stream_t *nst
       }
 
       nstrm->strm_errno = 0;
+      errno = EOF;
       break;
     }