From: Willy Tarreau Date: Fri, 16 Apr 2010 07:14:45 +0000 (+0200) Subject: [MINOR] fix possible crash in debug mode with invalid responses X-Git-Tag: v1.4.5~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3bfeebdb498da7f87a35aa4c9333841c23dd4df;p=thirdparty%2Fhaproxy.git [MINOR] fix possible crash in debug mode with invalid responses When trying to display an invalid request or response we received, we must at least check that we have identified something looking like a start of message, otherwise we can dereference a NULL pointer. --- diff --git a/src/proto_http.c b/src/proto_http.c index 0f6f77bb7b..882f0dc4dc 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -2408,6 +2408,7 @@ int http_wait_for_request(struct session *s, struct buffer *req, int an_bit) /* 1: we might have to print this header in debug mode */ if (unlikely((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) && + msg->sol && (msg->msg_state >= HTTP_MSG_BODY || msg->msg_state == HTTP_MSG_ERROR))) { char *eol, *sol; @@ -4312,6 +4313,7 @@ int http_wait_for_response(struct session *s, struct buffer *rep, int an_bit) /* 1: we might have to print this header in debug mode */ if (unlikely((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) && + msg->sol && (msg->msg_state >= HTTP_MSG_BODY || msg->msg_state == HTTP_MSG_ERROR))) { char *eol, *sol;