8d2dcd
--- a/modules/lua/lua_request.c	2022/03/07 14:48:54	1898693
8d2dcd
+++ b/modules/lua/lua_request.c	2022/03/07 14:51:19	1898694
8d2dcd
@@ -235,14 +235,16 @@
8d2dcd
 {
8d2dcd
     int rc = OK;
8d2dcd
 
8d2dcd
+    *rbuf = NULL;
8d2dcd
+    *size = 0;
8d2dcd
+
8d2dcd
     if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
8d2dcd
         return (rc);
8d2dcd
     }
8d2dcd
     if (ap_should_client_block(r)) {
8d2dcd
 
8d2dcd
         /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
8d2dcd
-        char         argsbuffer[HUGE_STRING_LEN];
8d2dcd
-        apr_off_t    rsize, len_read, rpos = 0;
8d2dcd
+        apr_off_t    len_read, rpos = 0;
8d2dcd
         apr_off_t length = r->remaining;
8d2dcd
         /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
8d2dcd
 
8d2dcd
@@ -250,18 +252,18 @@
8d2dcd
             return APR_EINCOMPLETE; /* Only room for incomplete data chunk :( */
8d2dcd
         }
8d2dcd
         *rbuf = (const char *) apr_pcalloc(r->pool, (apr_size_t) (length + 1));
8d2dcd
-        *size = length;
8d2dcd
-        while ((len_read = ap_get_client_block(r, argsbuffer, sizeof(argsbuffer))) > 0) {
8d2dcd
-            if ((rpos + len_read) > length) {
8d2dcd
-                rsize = length - rpos;
8d2dcd
-            }
8d2dcd
-            else {
8d2dcd
-                rsize = len_read;
8d2dcd
-            }
8d2dcd
-
8d2dcd
-            memcpy((char *) *rbuf + rpos, argsbuffer, (size_t) rsize);
8d2dcd
-            rpos += rsize;
8d2dcd
+        while ((rpos < length)
8d2dcd
+               && (len_read = ap_get_client_block(r, (char *) *rbuf + rpos,
8d2dcd
+                                               length - rpos)) > 0) {
8d2dcd
+            rpos += len_read;
8d2dcd
         }
8d2dcd
+        if (len_read < 0) {
8d2dcd
+            return APR_EINCOMPLETE;
8d2dcd
+        }
8d2dcd
+        *size = rpos;
8d2dcd
+    }
8d2dcd
+    else {
8d2dcd
+        rc = DONE;
8d2dcd
     }
8d2dcd
 
8d2dcd
     return (rc);
8d2dcd
@@ -278,6 +280,8 @@
8d2dcd
 {
8d2dcd
     apr_status_t rc = OK;
8d2dcd
 
8d2dcd
+    *size = 0;
8d2dcd
+
8d2dcd
     if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
8d2dcd
         return rc;
8d2dcd
     if (ap_should_client_block(r)) {
8d2dcd
@@ -303,6 +307,9 @@
8d2dcd
             rpos += rsize;
8d2dcd
         }
8d2dcd
     }
8d2dcd
+    else {
8d2dcd
+        rc = DONE;
8d2dcd
+    }
8d2dcd
 
8d2dcd
     return rc;
8d2dcd
 }