|
|
310e38 |
From 8c14927162cf3b4f810683e1c5505e9ef9e1f123 Mon Sep 17 00:00:00 2001
|
|
|
310e38 |
From: Eric Covener <covener@apache.org>
|
|
|
310e38 |
Date: Wed, 1 Jun 2022 12:34:16 +0000
|
|
|
310e38 |
Subject: [PATCH] Merge r1901500 from trunk:
|
|
|
310e38 |
|
|
|
310e38 |
handle large writes in ap_rputs
|
|
|
310e38 |
|
|
|
310e38 |
|
|
|
310e38 |
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1901501 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
310e38 |
---
|
|
|
310e38 |
include/http_protocol.h | 22 +++++++++++++++++++++-
|
|
|
310e38 |
server/protocol.c | 3 +++
|
|
|
310e38 |
2 files changed, 24 insertions(+), 1 deletion(-)
|
|
|
310e38 |
|
|
|
310e38 |
diff --git a/include/http_protocol.h b/include/http_protocol.h
|
|
|
310e38 |
index 20bd2022266..94c481e5f43 100644
|
|
|
310e38 |
--- a/include/http_protocol.h
|
|
|
310e38 |
+++ b/include/http_protocol.h
|
|
|
310e38 |
@@ -475,7 +475,27 @@ AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
|
|
|
310e38 |
*/
|
|
|
310e38 |
static APR_INLINE int ap_rputs(const char *str, request_rec *r)
|
|
|
310e38 |
{
|
|
|
310e38 |
- return ap_rwrite(str, (int)strlen(str), r);
|
|
|
310e38 |
+ apr_size_t len;
|
|
|
310e38 |
+
|
|
|
310e38 |
+ len = strlen(str);
|
|
|
310e38 |
+
|
|
|
310e38 |
+ for (;;) {
|
|
|
310e38 |
+ if (len <= INT_MAX) {
|
|
|
310e38 |
+ return ap_rwrite(str, (int)len, r);
|
|
|
310e38 |
+ }
|
|
|
310e38 |
+ else {
|
|
|
310e38 |
+ int rc;
|
|
|
310e38 |
+
|
|
|
310e38 |
+ rc = ap_rwrite(str, INT_MAX, r);
|
|
|
310e38 |
+ if (rc < 0) {
|
|
|
310e38 |
+ return rc;
|
|
|
310e38 |
+ }
|
|
|
310e38 |
+ else {
|
|
|
310e38 |
+ str += INT_MAX;
|
|
|
310e38 |
+ len -= INT_MAX;
|
|
|
310e38 |
+ }
|
|
|
310e38 |
+ }
|
|
|
310e38 |
+ }
|
|
|
310e38 |
}
|
|
|
310e38 |
|
|
|
310e38 |
/**
|
|
|
310e38 |
diff --git a/server/protocol.c b/server/protocol.c
|
|
|
310e38 |
index 298f61e1fb8..7adc7f75c10 100644
|
|
|
310e38 |
--- a/server/protocol.c
|
|
|
310e38 |
+++ b/server/protocol.c
|
|
|
310e38 |
@@ -2128,6 +2128,9 @@ AP_DECLARE(int) ap_rputc(int c, request_rec *r)
|
|
|
310e38 |
|
|
|
310e38 |
AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r)
|
|
|
310e38 |
{
|
|
|
310e38 |
+ if (nbyte < 0)
|
|
|
310e38 |
+ return -1;
|
|
|
310e38 |
+
|
|
|
310e38 |
if (r->connection->aborted)
|
|
|
310e38 |
return -1;
|
|
|
310e38 |
|