]> granicus.if.org Git - apache/commitdiff
create the brigate outside ap_proxygetline and reuse it.
authorJean-Frederic Clere <jfclere@apache.org>
Wed, 1 Aug 2007 12:20:34 +0000 (12:20 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Wed, 1 Aug 2007 12:20:34 +0000 (12:20 +0000)
correct the overflow handling. (returning APR_ENOSPC was
changing the behaviour).

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@561778 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy_http.c

index ae4b6285e4b39ae5e21e44566071ea64bfb0db9a..8e45d8e845ec1dd75684b24904fdcf14c510a55a 100644 (file)
@@ -1184,20 +1184,20 @@ static int addit_dammit(void *v, const char *key, const char *val)
 }
 
 static
-apr_status_t ap_proxygetline(char *s, int n, request_rec *r,
+apr_status_t ap_proxygetline(apr_bucket_brigade *bb, char *s, int n, request_rec *r,
                              int fold, int *writen)
 {
     char *tmp_s = s;
     apr_status_t rv;
     apr_size_t len;
-    apr_bucket_brigade *tmp_bb;
 
-    tmp_bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
-    rv = ap_rgetline(&tmp_s, n, &len, r, fold, tmp_bb);
-    apr_brigade_destroy(tmp_bb);
+    rv = ap_rgetline(&tmp_s, n, &len, r, fold, bb);
+    apr_brigade_cleanup(bb);
 
     if (rv == APR_SUCCESS) {
         *writen = (int) len;
+    } else if (rv == APR_ENOSPC) {
+        *writen = n;
     } else {
         *writen = -1;
     }
@@ -1217,7 +1217,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
     char keepchar;
     request_rec *rp;
     apr_bucket *e;
-    apr_bucket_brigade *bb;
+    apr_bucket_brigade *bb, *tmp_bb;
     int len, backasswards;
     int interim_response; /* non-zero whilst interim 1xx responses
                            * are being read. */
@@ -1236,15 +1236,16 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
      * response.
      */
     rp->proxyreq = PROXYREQ_RESPONSE;
+    tmp_bb = apr_brigade_create(p, c->bucket_alloc);
     do {
         apr_status_t rc;
 
         apr_brigade_cleanup(bb);
 
-        rc = ap_proxygetline(buffer, sizeof(buffer), rp, 0, &len);
+        rc = ap_proxygetline(tmp_bb, buffer, sizeof(buffer), rp, 0, &len);
         if (len == 0) {
             /* handle one potential stray CRLF */
-            rc = ap_proxygetline(buffer, sizeof(buffer), rp, 0, &len);
+            rc = ap_proxygetline(tmp_bb, buffer, sizeof(buffer), rp, 0, &len);
         }
         if (len <= 0) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,