]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] 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>
Thu, 28 Jan 2010 22:16:17 +0000 (23:16 +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.
(cherry picked from commit 58cc872848314ef2ecbaf9808ce4bd5f5b20bb69)

src/proto_http.c

index 729a97a88bb2c36d94ea53dedefeb9439dcfd4eb..46528b5f39478364f4118210f0ae6434cbdfb3d4 100644 (file)
@@ -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;
                }