[BUG] 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.
diff --git a/src/proto_http.c b/src/proto_http.c
index 450921f..35b22b0 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -2606,7 +2606,7 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
*/
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;
}