]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] segfault on some erroneous configurations
authorWilly Tarreau <w@1wt.eu>
Thu, 1 Feb 2007 22:15:45 +0000 (23:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 1 Feb 2007 22:15:45 +0000 (23:15 +0100)
If captures were configured in a TCP-only listener, and
the logs were enabled, the proxy could segfault when
trying to scan the capture buffer which was NULL. Such
an erroneous configuration will not be possible anymore
soon, but let's avoid the problem for now by detecting
the NULL condition.

src/log.c

index 80528162152a408d0812ce3271353ccf69a7d1a9..52e2ecfef39786d77d1e7edf8e11183890ba83a1 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -349,7 +349,9 @@ void sess_log(struct session *s)
                h = tmpline;
 
                /* right now, header capture is limited to the frontend only */
-               if (fe->to_log & LW_REQHDR && (h < tmpline + sizeof(tmpline) - 10)) {
+               if (fe->to_log & LW_REQHDR &&
+                   hreq->req.cap &&
+                   (h < tmpline + sizeof(tmpline) - 10)) {
                        *(h++) = ' ';
                        *(h++) = '{';
                        for (hdr = 0; hdr < fe->nb_req_cap; hdr++) {
@@ -362,7 +364,9 @@ void sess_log(struct session *s)
                        *(h++) = '}';
                }
 
-               if (fe->to_log & LW_RSPHDR && (h < tmpline + sizeof(tmpline) - 7)) {
+               if (fe->to_log & LW_RSPHDR &&
+                   hreq->rsp.cap &&
+                   (h < tmpline + sizeof(tmpline) - 7)) {
                        *(h++) = ' ';
                        *(h++) = '{';
                        for (hdr = 0; hdr < fe->nb_rsp_cap; hdr++) {