]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: hlua: Use front SC to detect EOI in HTTP applets' receive functions
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 12 Jun 2023 07:16:27 +0000 (09:16 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 12 Jun 2023 07:16:29 +0000 (09:16 +0200)
When an HTTP applet tries to get request data, we must take care to properly
detect the end of the message. It an empty HTX message with the SC_FL_EOI
flag set on the front SC. However, an issue was introduced during the SC
refactoring performed in the 2.8. The backend SC is tested instead of the
frontend one.

Because of this bug, the receive functions hang because the test on
SC_FL_EOI flag never succeeds. Of course, by checking the frontend SC (the
opposite SC to the one attached to the appctx), it works.

This patch should fix the issue #2180. It must be backported to the 2.8.

src/hlua.c

index 742c82448b1e135128e46ad97cb62665e5b3dd42..ae0d412a4deddb955d47ebfd66304223ed19a981 100644 (file)
@@ -5353,7 +5353,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
        /* The message was fully consumed and no more data are expected
         * (EOM flag set).
         */
-       if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI))
+       if (htx_is_empty(htx) && (sc_opposite(sc)->flags & SC_FL_EOI))
                stop = 1;
 
        htx_to_buf(htx, &req->buf);
@@ -5445,7 +5445,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon
        /* The message was fully consumed and no more data are expected
         * (EOM flag set).
         */
-       if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI))
+       if (htx_is_empty(htx) && (sc_opposite(sc)->flags & SC_FL_EOI))
                len = 0;
 
        htx_to_buf(htx, &req->buf);