mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
BUG/MINOR: hlua: fixing hlua_http_msg_del_data behavior
GH issue #1885 reported that HTTPMessage.remove() did not work as expected. It turns out that underlying hlua_http_msg_del_data() function was not working properly due to input / output inversion as well as incorrect user offset handling. This patch fixes it so that the behavior is the one described in the documentation. This could be backported to 2.6 and 2.5.
This commit is contained in:
parent
c5daf2801a
commit
d7c71b03d8
@ -6724,17 +6724,17 @@ __LJMP static int hlua_http_msg_del_data(lua_State *L)
|
|||||||
if (msg->msg_state < HTTP_MSG_DATA)
|
if (msg->msg_state < HTTP_MSG_DATA)
|
||||||
WILL_LJMP(lua_error(L));
|
WILL_LJMP(lua_error(L));
|
||||||
|
|
||||||
filter = hlua_http_msg_filter(L, 1, msg, &input, &output);
|
filter = hlua_http_msg_filter(L, 1, msg, &output, &input);
|
||||||
if (!filter || !hlua_filter_from_payload(filter))
|
if (!filter || !hlua_filter_from_payload(filter))
|
||||||
WILL_LJMP(lua_error(L));
|
WILL_LJMP(lua_error(L));
|
||||||
|
|
||||||
offset = input + output;
|
offset = output;
|
||||||
if (lua_gettop(L) > 1) {
|
if (lua_gettop(L) > 1) {
|
||||||
offset = MAY_LJMP(luaL_checkinteger(L, 2));
|
offset = MAY_LJMP(luaL_checkinteger(L, 2));
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
offset = MAX(0, (int)input + offset);
|
offset = MAX(0, (int)input + offset);
|
||||||
offset += output;
|
offset += output;
|
||||||
if (offset < output || offset > output + input) {
|
if (offset > output + input) {
|
||||||
lua_pushfstring(L, "offset out of range.");
|
lua_pushfstring(L, "offset out of range.");
|
||||||
WILL_LJMP(lua_error(L));
|
WILL_LJMP(lua_error(L));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user