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.
This commit is contained in:
Willy Tarreau 2015-09-26 11:50:08 +02:00
parent de70fa17a9
commit 9af89f7905

View File

@ -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;
}