]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] http: typos on several unlikely() around header insertion
authorWilly Tarreau <w@1wt.eu>
Mon, 28 Dec 2009 05:57:33 +0000 (06:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 28 Dec 2009 05:57:33 +0000 (06:57 +0100)
In many places where we perform header insertion, an error control
is performed but due to a mistake, it cannot match any error :

   if (unlikely(error) < 0)
instead of
   if (unlikely(error < 0))

This prevents error 400 responses from being sent when the buffer is
full due to many header additions. This must be backported to 1.3.

src/proto_http.c

index 450921f3ccdf757775f9f17734f8345037f81dc0..35b22b07952579026d93548de2f0e4ebcad5f6e5 100644 (file)
@@ -2606,7 +2606,7 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
                if (unlikely(http_header_add_tail(req,
                                                  &txn->req,
                                                  &txn->hdr_idx,
-                                                 px->req_add[cur_idx])) < 0)
+                                                 px->req_add[cur_idx]) < 0))
                        goto return_bad_req;
        }
 
@@ -2856,7 +2856,7 @@ int http_process_request(struct session *s, struct buffer *req, int an_bit)
                                len += sprintf(trash + len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]);
 
                                if (unlikely(http_header_add_tail2(req, &txn->req,
-                                                                  &txn->hdr_idx, trash, len)) < 0)
+                                                                  &txn->hdr_idx, trash, len) < 0))
                                        goto return_bad_req;
                        }
                }
@@ -2885,7 +2885,7 @@ int http_process_request(struct session *s, struct buffer *req, int an_bit)
                        len += sprintf(trash + len, ": %s", pn);
 
                        if (unlikely(http_header_add_tail2(req, &txn->req,
-                                                          &txn->hdr_idx, trash, len)) < 0)
+                                                          &txn->hdr_idx, trash, len) < 0))
                                goto return_bad_req;
                }
        }
@@ -2929,7 +2929,7 @@ int http_process_request(struct session *s, struct buffer *req, int an_bit)
                                len += sprintf(trash + len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]);
 
                                if (unlikely(http_header_add_tail2(req, &txn->req,
-                                                                  &txn->hdr_idx, trash, len)) < 0)
+                                                                  &txn->hdr_idx, trash, len) < 0))
                                        goto return_bad_req;
                        }
                }
@@ -2938,7 +2938,7 @@ int http_process_request(struct session *s, struct buffer *req, int an_bit)
        /* 11: add "Connection: close" if needed and not yet set. */
        if (!(txn->flags & TX_REQ_CONN_CLO) && ((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL)) {
                if (unlikely(http_header_add_tail2(req, &txn->req, &txn->hdr_idx,
-                                                  "Connection: close", 17)) < 0)
+                                                  "Connection: close", 17) < 0))
                        goto return_bad_req;
                txn->flags |= TX_REQ_CONN_CLO;
        }
@@ -3930,7 +3930,7 @@ int http_process_res_common(struct session *t, struct buffer *rep, int an_bit, s
                                if (txn->status < 200)
                                        break;
                                if (unlikely(http_header_add_tail(rep, &txn->rsp, &txn->hdr_idx,
-                                                                 rule_set->rsp_add[cur_idx])) < 0)
+                                                                 rule_set->rsp_add[cur_idx]) < 0))
                                        goto return_bad_resp;
                        }
 
@@ -3991,7 +3991,7 @@ int http_process_res_common(struct session *t, struct buffer *rep, int an_bit, s
                                len += sprintf(trash+len, "; domain=%s", t->be->cookie_domain);
 
                        if (unlikely(http_header_add_tail2(rep, &txn->rsp, &txn->hdr_idx,
-                                                          trash, len)) < 0)
+                                                          trash, len) < 0))
                                goto return_bad_resp;
                        txn->flags |= TX_SCK_INSERTED;
 
@@ -4005,7 +4005,7 @@ int http_process_res_common(struct session *t, struct buffer *rep, int an_bit, s
                                txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK;
 
                                if (unlikely(http_header_add_tail2(rep, &txn->rsp, &txn->hdr_idx,
-                                                                  "Cache-control: private", 22)) < 0)
+                                                                  "Cache-control: private", 22) < 0))
                                        goto return_bad_resp;
                        }
                }
@@ -4045,7 +4045,7 @@ int http_process_res_common(struct session *t, struct buffer *rep, int an_bit, s
                 */
                if (must_close && (txn->flags & TX_RES_VER_11)) {
                        if (unlikely(http_header_add_tail2(rep, &txn->rsp, &txn->hdr_idx,
-                                                          "Connection: close", 17)) < 0)
+                                                          "Connection: close", 17) < 0))
                                goto return_bad_resp;
                        must_close = 0;
                }