]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua funtion hlua_socket_settimeout don't check negative values
authorThierry Fournier <thierry.fournier@ozon.io>
Thu, 8 Mar 2018 08:59:02 +0000 (09:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Mar 2018 09:11:49 +0000 (11:11 +0200)
Negatives timeouts doesn't have sense. A negative timeout doesn't cause
a crash, but the connection expires before the system try to extablish it.

This patch should be backported in all versions from 1.6

src/hlua.c

index 3b87aa94f27c889e0b2ff0107d7f100ae6965249..1541468f2b7ee6bf6e61de45bb018c0f0cf704c5 100644 (file)
@@ -2474,6 +2474,10 @@ __LJMP static int hlua_socket_settimeout(struct lua_State *L)
        socket = MAY_LJMP(hlua_checksocket(L, 1));
        tmout = MAY_LJMP(luaL_checkinteger(L, 2)) * 1000;
 
+       /* Check for negative values */
+       if (tmout < 0)
+               WILL_LJMP(luaL_error(L, "settimeout: cannot set negatives values"));
+
        /* Check if we run on the same thread than the xreator thread.
         * We cannot access to the socket if the thread is different.
         */