]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua/htx: Handle EOM in receive/get_line calls in HTTP applets
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 18 Dec 2018 15:43:35 +0000 (16:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 19 Dec 2018 12:45:53 +0000 (13:45 +0100)
In HTTP applets, the request's EOM was removed like other blocks when receive or
get_line was called from lua scripts. So it was impossible to stop receiving
data on successive calls when all the request body was already consumed,
blocking infinitly the applet.

Now, we never consume the EOM. So it is easy to interrupt receive/get_line
calls. In all cases, this block is consumed when the applet ends.

src/hlua.c

index 13e03cef732351bf1e623957b27eb2a2df24440a..79b486da8eb6b6f31c3fef3923058ea0c23f9167 100644 (file)
@@ -4240,6 +4240,11 @@ __LJMP static int hlua_applet_htx_getline_yield(lua_State *L, int status, lua_KC
                uint32_t vlen;
                char *nl;
 
+               if (type == HTX_BLK_EOM) {
+                       stop = 1;
+                       break;
+               }
+
                vlen = sz;
                if (vlen > count) {
                        if (type != HTX_BLK_DATA)
@@ -4409,6 +4414,11 @@ __LJMP static int hlua_applet_htx_recv_yield(lua_State *L, int status, lua_KCont
                struct ist v;
                uint32_t vlen;
 
+               if (type == HTX_BLK_EOM) {
+                       len = 0;
+                       break;
+               }
+
                vlen = sz;
                if (len > 0 && vlen > len)
                        vlen = len;