From: Willy Tarreau Date: Sat, 26 Sep 2015 09:50:08 +0000 (+0200) Subject: BUG/MEDIUM: lua: better fix for the protocol check X-Git-Tag: v1.6-dev6~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9af89f79057084bf8e7f4900333fda187475ca4a;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: lua: better fix for the protocol check Commit d75cb0f ("BUG/MAJOR: lua: segfault after the channel data is modified by some Lua action.") introduced a regression causing an action run from a TCP rule in an HTTP proxy to end in HTTP error if it terminated cleanly, because it didn't parse the HTTP request! Relax the test so that it takes into account the opportunity for the analysers to parse the message. --- diff --git a/src/hlua.c b/src/hlua.c index e34658c3a9..d2a2110783 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2403,15 +2403,22 @@ static int hlua_check_proto(struct stream *stream, int dir) { const struct chunk msg = { .len = 0 }; - /* Protocol HTTP. The message parsing state must be in accord - * with the request or response state. + /* Protocol HTTP. The message parsing state must match the request or + * response state. The problem that may happen is that Lua modifies + * the request or response message *after* it was parsed, and corrupted + * it so that it could not be processed anymore. We just need to verify + * if the parser is still expected to run or not. */ if (stream->be->mode == PR_MODE_HTTP) { - if (dir == 0 && stream->txn->req.msg_state < HTTP_MSG_BODY) { + if (dir == 0 && + !(stream->req.analysers & AN_REQ_WAIT_HTTP) && + stream->txn->req.msg_state < HTTP_MSG_BODY) { stream_int_retnclose(&stream->si[0], &msg); return 0; } - else if (dir == 1 && stream->txn->rsp.msg_state < HTTP_MSG_BODY) { + else if (dir == 1 && + !(stream->res.analysers & AN_RES_WAIT_HTTP) && + stream->txn->rsp.msg_state < HTTP_MSG_BODY) { stream_int_retnclose(&stream->si[0], &msg); return 0; }