]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: lua: send function fails and return bad bytes
authorThierry FOURNIER <tfournier@exceliance.fr>
Wed, 4 Mar 2015 10:44:47 +0000 (11:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Mar 2015 12:36:41 +0000 (13:36 +0100)
In some cases the Lua "send" function fails. This is caused by the
return of "buffer_replace2()" is not tested. I checked avalaible space
in the buffer and I supposed than "buffer_replace2()" took all the
data. In some cases, "buffer_replace2()" cannot take the incoming
data, it returns the amount of data copied.

This patch check the amount of data really copied by "buffer_replace2()"
and advance the buffer with taking this value in account.

src/hlua.c

index 1df18b66ad54678583e7f63f81f49713a20211db..d3f302f0b91283a05fbdf6d7a53e6086441118fc 100644 (file)
@@ -2091,7 +2091,7 @@ __LJMP static int _hlua_channel_send(lua_State *L)
        if (max > len - l)
                max = len - l;
 
-       buffer_replace2(chn->chn->buf, chn->chn->buf->p, chn->chn->buf->p, str+l, max);
+       max = buffer_replace2(chn->chn->buf, chn->chn->buf->p, chn->chn->buf->p, str+l, max);
        /* buffer replace considers that the input part is filled.
         * so, I must forward these new data in the output part.
         */