Package: luasocket
Version: 2.0.2-3

A lua library it should only support its luaopen_* functions, but it exports 
many other symbols, including for example buffer_init.
The other exported symbols are used (and exported to support loading plugins) 
in other binaries, for example in lighttpd; if now one loads the lua socket 
library via mod_magnet in lighty, the lua socket library will use the 
buffer_init from lighty, leading to segfaults in the lua library.

The solution is to only export the luaopen_* functions.

Btw: installing the "unix.h" header is pointless as i needs other headers as 
well. Perhaps installing a different header as unix.h would be better to only 
provide luaopen_socket_unix().

If you want to test this yourself, make a simple binary loading the echo-
server example from the luasocket homepage and export a buffer_init in it; 
compile with -export-dynamic.

For now i have a simple example:
http://stbuehler.de/tmp/luasockettest.tar.bz2

Greetings,
Stefan
commit 5440201de4bcfc0fcfbc1f735465e82b08c74cf3
Author: Stefan Bühler <stbueh...@web.de>
Date:   Tue Jul 14 16:59:49 2009 +0200

    Use a map for exported symbols

diff --git a/Makefile.Debian b/Makefile.Debian
index 88a1d21..2b4ae84 100644
--- a/Makefile.Debian
+++ b/Makefile.Debian
@@ -40,15 +40,15 @@ lua50/liblua50-socket.la: $(SOCKET_OBJS_50)
 lua50/liblua50-mime.la: $(MIME_OBJS_50)
 lua50/liblua50-unix.la: $(UNIX_OBJS_50)
 lua5.1/%.lo: src/%.c
-	$(LBTL) --mode=compile $(CC) -c $(GCC_FLAGS_51) -o $@ $< 
+	$(LBTL) --mode=compile $(CC) -c $(GCC_FLAGS_51) -o $@ $<
 lua50/%.lo: src/%.c
 	$(LBTL) --mode=compile $(CC) -c $(GCC_FLAGS_50) -o $@ $< 
 lua50/%.la:
-	$(LBTL) --mode=link $(CC) \
-	    -rpath $(LUA_RPATH_50) -o $@ -version-info $(VERSION_INFO) $^
+	$(LBTL) --mode=link $(CC) -llua50 \
+	    -rpath $(LUA_RPATH_50) -o $@ -version-info $(VERSION_INFO) $^ -Wl,--version-script=src/export.map
 lua5.1/%.la:
 	$(LBTL) --mode=link $(CC) \
-	    -rpath $(LUA_RPATH_51) -o $@ -version-info $(VERSION_INFO) $^
+	    -rpath $(LUA_RPATH_51) -llua5.1 -o $@ -version-info $(VERSION_INFO) $^ -Wl,--version-script=src/export.map
 install-bin: install-bin50 install-bin51
 install-bin50:
 	mkdir -p $(DESTDIR)/usr/lib/
diff --git a/config b/config
index 49958eb..81ac6da 100644
--- a/config
+++ b/config
@@ -52,7 +52,7 @@ INSTALL_EXEC=cp
 CC=gcc
 DEF=-DLUASOCKET_DEBUG 
 CFLAGS= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic
-LDFLAGS=-O -shared -fpic
+LDFLAGS=-O -shared -fpic -Wl,--version-script=export.map
 LD=gcc 
 
 #------
diff --git a/src/export.map b/src/export.map
new file mode 100644
index 0000000..71ee4f3
--- /dev/null
+++ b/src/export.map
@@ -0,0 +1,4 @@
+{
+	global: luaopen_*;
+	local: *;
+};

Reply via email to