Date: Fri, 21 Aug 2009 23:37:24 +0200 From: Robert Nagy <robert@openbsd.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/138055: luasocket namespace clash with lighttpd mod_magnet Message-ID: <20090821213724.GA18234@bsd.hu> Resent-Message-ID: <200908212200.n7LM0ClR042206@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 138055 >Category: ports >Synopsis: luasocket namespace clash with lighttpd mod_magnet >Confidential: no >Severity: critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Aug 21 22:00:12 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Robert Nagy >Release: FreeBSD 8.0-BETA2 amd64 >Organization: >Environment: System: FreeBSD x2100.humppa.hu 8.0-BETA2 FreeBSD 8.0-BETA2 #0: Sun Aug 16 20:24:48 CEST 2009 root@x2100.humppa.hu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: Basically - luasocket defines buffer_init(); which is common enough to be defined elsewhere and it is defined in mod_magnet, so you end up with a SIGSEGV. The attatched patch solves the issue by renaming the buffer_* funcs to ls_buffer_*. Its a totally safe diff that does not affect anything else and fixes a problem. >How-To-Repeat: Write a lua script that uses luasocket and try to use it with mod_magnet. >Fix: Index: Makefile =================================================================== RCS file: /home/ncvs/ports/net/luasocket/Makefile,v retrieving revision 1.12 diff -u -r1.12 Makefile --- Makefile 9 Jul 2009 03:57:57 -0000 1.12 +++ Makefile 21 Aug 2009 21:22:24 -0000 @@ -7,6 +7,7 @@ PORTNAME= luasocket PORTVERSION= 2.0.2 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= http://luaforge.net/frs/download.php/2664/ PKGNAMEPREFIX= ${LUA_PKGNAMEPREFIX} Index: files/patch-src_buffer_c =================================================================== RCS file: files/patch-src_buffer_c diff -N files/patch-src_buffer_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-src_buffer_c 21 Aug 2009 21:22:24 -0000 @@ -0,0 +1,233 @@ +diff -ru src/buffer.c src/buffer.c +--- src/buffer.c 2008-08-20 06:16:42 +0000 ++++ src/buffer.c 2008-08-20 06:30:15 +0000 +@@ -33,7 +33,7 @@ + /*-------------------------------------------------------------------------*\ + * Initializes module + \*-------------------------------------------------------------------------*/ +-int buffer_open(lua_State *L) { ++int ls_buffer_open(lua_State *L) { + (void) L; + return 0; + } +@@ -41,7 +41,7 @@ + /*-------------------------------------------------------------------------*\ + * Initializes C structure + \*-------------------------------------------------------------------------*/ +-void buffer_init(p_buffer buf, p_io io, p_timeout tm) { ++void ls_buffer_init(p_buffer buf, p_io io, p_timeout tm) { + buf->first = buf->last = 0; + buf->io = io; + buf->tm = tm; +@@ -52,7 +52,7 @@ + /*-------------------------------------------------------------------------*\ + * object:getstats() interface + \*-------------------------------------------------------------------------*/ +-int buffer_meth_getstats(lua_State *L, p_buffer buf) { ++int ls_buffer_meth_getstats(lua_State *L, p_buffer buf) { + lua_pushnumber(L, buf->received); + lua_pushnumber(L, buf->sent); + lua_pushnumber(L, timeout_gettime() - buf->birthday); +@@ -62,7 +62,7 @@ + /*-------------------------------------------------------------------------*\ + * object:setstats() interface + \*-------------------------------------------------------------------------*/ +-int buffer_meth_setstats(lua_State *L, p_buffer buf) { ++int ls_buffer_meth_setstats(lua_State *L, p_buffer buf) { + buf->received = (long) luaL_optnumber(L, 2, buf->received); + buf->sent = (long) luaL_optnumber(L, 3, buf->sent); + if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4); +@@ -73,7 +73,7 @@ + /*-------------------------------------------------------------------------*\ + * object:send() interface + \*-------------------------------------------------------------------------*/ +-int buffer_meth_send(lua_State *L, p_buffer buf) { ++int ls_buffer_meth_send(lua_State *L, p_buffer buf) { + int top = lua_gettop(L); + int err = IO_DONE; + size_t size = 0, sent = 0; +@@ -106,7 +106,7 @@ + /*-------------------------------------------------------------------------*\ + * object:receive() interface + \*-------------------------------------------------------------------------*/ +-int buffer_meth_receive(lua_State *L, p_buffer buf) { ++int ls_buffer_meth_receive(lua_State *L, p_buffer buf) { + int err = IO_DONE, top = lua_gettop(L); + luaL_Buffer b; + size_t size; +@@ -149,7 +149,7 @@ + /*-------------------------------------------------------------------------*\ + * Determines if there is any data in the read buffer + \*-------------------------------------------------------------------------*/ +-int buffer_isempty(p_buffer buf) { ++int ls_buffer_isempty(p_buffer buf) { + return buf->first >= buf->last; + } + +@@ -244,7 +244,7 @@ + static void buffer_skip(p_buffer buf, size_t count) { + buf->received += count; + buf->first += count; +- if (buffer_isempty(buf)) ++ if (ls_buffer_isempty(buf)) + buf->first = buf->last = 0; + } + +@@ -256,7 +256,7 @@ + int err = IO_DONE; + p_io io = buf->io; + p_timeout tm = buf->tm; +- if (buffer_isempty(buf)) { ++ if (ls_buffer_isempty(buf)) { + size_t got; + err = io->recv(io->ctx, buf->data, BUF_SIZE, &got, tm); + buf->first = 0; +diff -ru src/buffer.h src/buffer.h +--- src/buffer.h 2008-08-20 06:16:42 +0000 ++++ src/buffer.h 2008-08-20 06:30:15 +0000 +@@ -36,12 +36,12 @@ + } t_buffer; + typedef t_buffer *p_buffer; + +-int buffer_open(lua_State *L); +-void buffer_init(p_buffer buf, p_io io, p_timeout tm); +-int buffer_meth_send(lua_State *L, p_buffer buf); +-int buffer_meth_receive(lua_State *L, p_buffer buf); +-int buffer_meth_getstats(lua_State *L, p_buffer buf); +-int buffer_meth_setstats(lua_State *L, p_buffer buf); +-int buffer_isempty(p_buffer buf); ++int ls_buffer_open(lua_State *L); ++void ls_buffer_init(p_buffer buf, p_io io, p_timeout tm); ++int ls_buffer_meth_send(lua_State *L, p_buffer buf); ++int ls_buffer_meth_receive(lua_State *L, p_buffer buf); ++int ls_buffer_meth_getstats(lua_State *L, p_buffer buf); ++int ls_buffer_meth_setstats(lua_State *L, p_buffer buf); ++int ls_buffer_isempty(p_buffer buf); + + #endif /* BUF_H */ +diff -ru src/luasocket.c src/luasocket.c +--- src/luasocket.c 2008-08-20 06:16:42 +0000 ++++ src/luasocket.c 2008-08-20 06:30:15 +0000 +@@ -51,7 +51,7 @@ + {"auxiliar", auxiliar_open}, + {"except", except_open}, + {"timeout", timeout_open}, +- {"buffer", buffer_open}, ++ {"buffer", ls_buffer_open}, + {"inet", inet_open}, + {"tcp", tcp_open}, + {"udp", udp_open}, +diff -ru src/tcp.c src/tcp.c +--- src/tcp.c 2008-08-20 06:16:42 +0000 ++++ src/tcp.c 2008-08-20 06:30:15 +0000 +@@ -104,22 +104,22 @@ + \*-------------------------------------------------------------------------*/ + static int meth_send(lua_State *L) { + p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); +- return buffer_meth_send(L, &tcp->buf); ++ return ls_buffer_meth_send(L, &tcp->buf); + } + + static int meth_receive(lua_State *L) { + p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); +- return buffer_meth_receive(L, &tcp->buf); ++ return ls_buffer_meth_receive(L, &tcp->buf); + } + + static int meth_getstats(lua_State *L) { + p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); +- return buffer_meth_getstats(L, &tcp->buf); ++ return ls_buffer_meth_getstats(L, &tcp->buf); + } + + static int meth_setstats(lua_State *L) { + p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); +- return buffer_meth_setstats(L, &tcp->buf); ++ return ls_buffer_meth_setstats(L, &tcp->buf); + } + + /*-------------------------------------------------------------------------*\ +@@ -152,7 +152,7 @@ + static int meth_dirty(lua_State *L) + { + p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); +- lua_pushboolean(L, !buffer_isempty(&tcp->buf)); ++ lua_pushboolean(L, !ls_buffer_isempty(&tcp->buf)); + return 1; + } + +@@ -176,7 +176,7 @@ + io_init(&clnt->io, (p_send) socket_send, (p_recv) socket_recv, + (p_error) socket_ioerror, &clnt->sock); + timeout_init(&clnt->tm, -1, -1); +- buffer_init(&clnt->buf, &clnt->io, &clnt->tm); ++ ls_buffer_init(&clnt->buf, &clnt->io, &clnt->tm); + return 1; + } else { + lua_pushnil(L); +@@ -329,7 +329,7 @@ + io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv, + (p_error) socket_ioerror, &tcp->sock); + timeout_init(&tcp->tm, -1, -1); +- buffer_init(&tcp->buf, &tcp->io, &tcp->tm); ++ ls_buffer_init(&tcp->buf, &tcp->io, &tcp->tm); + return 1; + } else { + lua_pushnil(L); +diff -ru src/unix.c src/unix.c +--- src/unix.c 2008-08-20 06:16:42 +0000 ++++ src/unix.c 2008-08-20 06:30:15 +0000 +@@ -105,22 +105,22 @@ + \*-------------------------------------------------------------------------*/ + static int meth_send(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); +- return buffer_meth_send(L, &un->buf); ++ return ls_buffer_meth_send(L, &un->buf); + } + + static int meth_receive(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); +- return buffer_meth_receive(L, &un->buf); ++ return ls_buffer_meth_receive(L, &un->buf); + } + + static int meth_getstats(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); +- return buffer_meth_getstats(L, &un->buf); ++ return ls_buffer_meth_getstats(L, &un->buf); + } + + static int meth_setstats(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); +- return buffer_meth_setstats(L, &un->buf); ++ return ls_buffer_meth_setstats(L, &un->buf); + } + + /*-------------------------------------------------------------------------*\ +@@ -149,7 +149,7 @@ + + static int meth_dirty(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); +- lua_pushboolean(L, !buffer_isempty(&un->buf)); ++ lua_pushboolean(L, !ls_buffer_isempty(&un->buf)); + return 1; + } + +@@ -172,7 +172,7 @@ + io_init(&clnt->io, (p_send)socket_send, (p_recv)socket_recv, + (p_error) socket_ioerror, &clnt->sock); + timeout_init(&clnt->tm, -1, -1); +- buffer_init(&clnt->buf, &clnt->io, &clnt->tm); ++ ls_buffer_init(&clnt->buf, &clnt->io, &clnt->tm); + return 1; + } else { + lua_pushnil(L); +@@ -346,7 +346,7 @@ + io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv, + (p_error) socket_ioerror, &un->sock); + timeout_init(&un->tm, -1, -1); +- buffer_init(&un->buf, &un->io, &un->tm); ++ ls_buffer_init(&un->buf, &un->io, &un->tm); + return 1; + } else { + lua_pushnil(L); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090821213724.GA18234>