]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1901500 from trunk:
authorEric Covener <covener@apache.org>
Wed, 1 Jun 2022 12:34:16 +0000 (12:34 +0000)
committerEric Covener <covener@apache.org>
Wed, 1 Jun 2022 12:34:16 +0000 (12:34 +0000)
handle large writes in ap_rputs

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1901501 13f79535-47bb-0310-9956-ffa450edef68

include/http_protocol.h
server/protocol.c

index 20bd2022266b91c61136c4e1387c90106f362c0e..94c481e5f43d8b733c65173d24c6e604e53ec99a 100644 (file)
@@ -475,7 +475,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 298f61e1fb87549987bb0d8f1b05b0d3f5c2a791..7adc7f75c10bcd43028cbeb3885c76759a4f4d88 100644 (file)
@@ -2128,6 +2128,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;