From a8d6211be4e801abd596cdcc43bab8dbbe8aafd0 Mon Sep 17 00:00:00 2001 From: Peter Feuerer Date: Sun, 26 Oct 2014 02:24:05 +0200 Subject: [PATCH 1/4] Initialize address_len before accept() accept() could produce unexpected behavior in case the address_len is uninitialized, e.g. return -1 with EINVAL --- loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loop.c b/loop.c index 0d48cd4..6c8c81a 100644 --- a/loop.c +++ b/loop.c @@ -683,7 +683,7 @@ static void event_incoming (struct bufferevent *bev, short what, void *_arg) { static void accept_incoming (evutil_socket_t efd, short what, void *arg) { vlogprintf (E_WARNING, "Accepting incoming connection\n"); - unsigned clilen; + unsigned clilen = 0; struct sockaddr_in cli_addr; int fd = accept (efd, (struct sockaddr *)&cli_addr, &clilen); From b416aeece8cccec6a4cab39b289e21e4cd7459b3 Mon Sep 17 00:00:00 2001 From: Bas Westerbaan Date: Mon, 27 Oct 2014 20:55:55 +0100 Subject: [PATCH 2/4] README: update instructions for MacPorts --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9924e8..0819886 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,9 @@ If using [MacPorts](https://www.macports.org): sudo port install libconfig-hr sudo port install readline sudo port install lua51 - export CFLAGS="-I/usr/local/include -I/opt/local/include" - export LDFLAGS="-L/usr/local/lib -L/opt/local/lib/" + sudo port install libevent + export CFLAGS="-I/usr/local/include -I/opt/local/include -I/opt/local/include/lua-5.1" + export LDFLAGS="-L/usr/local/lib -L/opt/local/lib -L/opt/local/lib/lua-5.1" ./configure && make Install these ports: From 318f8d5828058c7918ccb9276e29c7998fe1468e Mon Sep 17 00:00:00 2001 From: Bas Westerbaan Date: Mon, 27 Oct 2014 20:58:44 +0100 Subject: [PATCH 3/4] tgl.h: add stdlib.h include This fixes the error ``` gcc -I. -I. -I/usr/local/include -I/opt/local/include -I/opt/local/include/lua-5.1 -I/usr/local/include -I/usr/include -I/usr/include -I/opt/local/include -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -c -MP -MD -MF ./dep/lua-tg.d -MQ ./objs/lua-tg.o -o objs/lua-tg.o lua-tg.c In file included from lua-tg.c:25: In file included from ./lua-tg.h:24: ./tgl.h:380:27: error: implicitly declaring library function 'malloc' with type 'void *(unsigned long)' [-Werror] struct tgl_state *TLS = malloc (sizeof (*TLS)); ^ ./tgl.h:380:27: note: please include the header or explicitly provide a declaration for 'malloc' 1 error generated. make: *** [objs/lua-tg.o] Error 1 ``` --- tgl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tgl.h b/tgl.h index 897a13e..8b981b7 100644 --- a/tgl.h +++ b/tgl.h @@ -22,6 +22,7 @@ #include #include +#include #define TGL_MAX_DC_NUM 100 #define TG_SERVER_1 "173.240.5.1" From 35e8622d64aca5e336dce5bc31d222514f73333d Mon Sep 17 00:00:00 2001 From: Massimo Santini Date: Thu, 30 Oct 2014 00:07:31 +0100 Subject: [PATCH 4/4] Bumper readline version (for homebrew on OSX) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9924e8..2adf04d 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,8 @@ If using [Homebrew](http://brew.sh/): brew install libconfig brew install readline brew install lua - export CFLAGS="-I/usr/local/include -I/usr/local/Cellar/readline/6.2.4/include" - export LDFLAGS="-L/usr/local/lib -L/usr/local/Cellar/readline/6.2.4/lib" + export CFLAGS="-I/usr/local/include -I/usr/local/Cellar/readline/6.3.8/include" + export LDFLAGS="-L/usr/local/lib -L/usr/local/Cellar/readline/6.3.8/lib" ./configure && make Thanks to [@jfontan](https://github.com/vysheng/tg/issues/3#issuecomment-28293731) for this solution.