]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
handle large writes in ap_rputs
authorEric Covener <covener@apache.org>
Wed, 1 Jun 2022 12:33:53 +0000 (12:33 +0000)
committerEric Covener <covener@apache.org>
Wed, 1 Jun 2022 12:33:53 +0000 (12:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901500 13f79535-47bb-0310-9956-ffa450edef68

include/http_protocol.h
server/protocol.c

index 4bfe4a855936eeecfdb8af69cd9690421ef81e5e..6979dc06e7c5ecb9d1419dfd0b160a28326ab7c0 100644 (file)
@@ -501,7 +501,27 @@ AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
  */
 static APR_INLINE int ap_rputs(const char *str, request_rec *r)
 {
-    return ap_rwrite(str, (int)strlen(str), r);
+    apr_size_t len;
+
+    len = strlen(str);
+
+    for (;;) {
+        if (len <= INT_MAX) {
+            return ap_rwrite(str, (int)len, r);
+        }
+        else {
+            int rc;
+
+            rc = ap_rwrite(str, INT_MAX, r);
+            if (rc < 0) {
+                return rc;
+            }
+            else {
+                str += INT_MAX;
+                len -= INT_MAX;
+            }
+        }
+    }
 }
 
 /**
index 8d9b4fd169c1ebec3c6c413d1816ec199375f9a6..3c33ec9b5fca970c9679c63cc6c89c5f3950e4b5 100644 (file)
@@ -2064,6 +2064,9 @@ AP_DECLARE(int) ap_rputc(int c, request_rec *r)
 
 AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r)
 {
+    if (nbyte < 0)
+        return -1;
+
     if (r->connection->aborted)
         return -1;