Blame SOURCES/httpd-2.4.34-CVE-2022-28614.patch

879b17
diff --git a/include/http_protocol.h b/include/http_protocol.h
879b17
index e1572dc..8ed77ac 100644
879b17
--- a/include/http_protocol.h
879b17
+++ b/include/http_protocol.h
879b17
@@ -439,7 +439,27 @@ AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
879b17
  */
879b17
 static APR_INLINE int ap_rputs(const char *str, request_rec *r)
879b17
 {
879b17
-    return ap_rwrite(str, (int)strlen(str), r);
879b17
+    apr_size_t len;
879b17
+
879b17
+    len = strlen(str);
879b17
+
879b17
+    for (;;) {
879b17
+        if (len <= INT_MAX) {
879b17
+            return ap_rwrite(str, (int)len, r);
879b17
+        }
879b17
+        else {
879b17
+            int rc;
879b17
+
879b17
+            rc = ap_rwrite(str, INT_MAX, r);
879b17
+            if (rc < 0) {
879b17
+                return rc;
879b17
+            }
879b17
+            else {
879b17
+                str += INT_MAX;
879b17
+                len -= INT_MAX;
879b17
+            }
879b17
+        }
879b17
+    }
879b17
 }
879b17
 
879b17
 /**
879b17
diff --git a/server/protocol.c b/server/protocol.c
879b17
index 476977f..a78eff6 100644
879b17
--- a/server/protocol.c
879b17
+++ b/server/protocol.c
879b17
@@ -2107,6 +2107,9 @@ AP_DECLARE(int) ap_rputc(int c, request_rec *r)
879b17
 
879b17
 AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r)
879b17
 {
879b17
+    if (nbyte < 0)
879b17
+        return -1;
879b17
+
879b17
     if (r->connection->aborted)
879b17
         return -1;
879b17