From 80b085003a90f23e4bdc5fe9b9ad88c047bc6e08 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 28 Dec 2009 06:57:33 +0100 Subject: [PATCH] [MINOR] http: typos on several unlikely() around header insertion 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. (cherry picked from commit 58cc872848314ef2ecbaf9808ce4bd5f5b20bb69) --- src/proto_http.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/proto_http.c b/src/proto_http.c index 729a97a88b..46528b5f39 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -2180,7 +2180,7 @@ int http_process_request(struct session *s, struct buffer *req) 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; } } @@ -2209,7 +2209,7 @@ int http_process_request(struct session *s, struct buffer *req) 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; } } @@ -2253,7 +2253,7 @@ int http_process_request(struct session *s, struct buffer *req) 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; } } @@ -2268,7 +2268,7 @@ int http_process_request(struct session *s, struct buffer *req) if ((unlikely(msg->sl.rq.v_l != 8) || unlikely(req->data[msg->som + msg->sl.rq.v + 7] != '0')) && unlikely(http_header_add_tail2(req, &txn->req, &txn->hdr_idx, - "Connection: close", 17)) < 0) + "Connection: close", 17) < 0)) goto return_bad_req; s->flags |= SN_CONN_CLOSED; } @@ -2873,7 +2873,7 @@ int process_response(struct session *t) 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; } @@ -2918,7 +2918,7 @@ int process_response(struct session *t) 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; @@ -2932,7 +2932,7 @@ int process_response(struct session *t) 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; } } @@ -2974,7 +2974,7 @@ int process_response(struct session *t) if ((unlikely(msg->sl.st.v_l != 8) || unlikely(req->data[msg->som + 7] != '0')) && unlikely(http_header_add_tail2(rep, &txn->rsp, &txn->hdr_idx, - "Connection: close", 17)) < 0) + "Connection: close", 17) < 0)) goto return_bad_resp; t->flags |= SN_CONN_CLOSED; } -- 2.47.3