commit 80277d270bb8d71258280683f17090ecb10d96ae Author: George Kadianakis desnacked@gmail.com Date: Mon Aug 22 17:32:12 2011 +0200
Fix issues pointed out at #3613.
* In network.c, remove all dangerous libevent asserts. * In util.c, turn abort()s in the logging code, to obfs_assert(). --- src/network.c | 10 ++-------- src/util.c | 8 +++----- 2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/src/network.c b/src/network.c index 91b1237..a1fbe41 100644 --- a/src/network.c +++ b/src/network.c @@ -102,7 +102,7 @@ static void pending_socks_cb(struct bufferevent *bev, short what, void *arg); struct evconnlistener * get_evconnlistener_by_config(config_t *cfg) { - obfs_assert(listeners); /* ? */ + obfs_assert(listeners);
SMARTLIST_FOREACH_BEGIN(listeners, listener_t *, l) { if (l->cfg == cfg) @@ -723,7 +723,6 @@ error_cb(struct bufferevent *bev, short what, void *arg) what, errcode);
/* It should be impossible to get here with BEV_EVENT_CONNECTED. */ - obfs_assert(what & (BEV_EVENT_EOF|BEV_EVENT_ERROR|BEV_EVENT_TIMEOUT)); obfs_assert(!(what & BEV_EVENT_CONNECTED));
if (what & BEV_EVENT_ERROR) { @@ -732,8 +731,7 @@ error_cb(struct bufferevent *bev, short what, void *arg) evutil_socket_error_to_string(errcode)); } else if (what & BEV_EVENT_EOF) { log_info("EOF from %s", conn->peername); - } else { - obfs_assert(what & BEV_EVENT_TIMEOUT); + } else if (what & BEV_EVENT_TIMEOUT) { log_info("Timeout talking to %s", conn->peername); } error_or_eof(conn); @@ -752,7 +750,6 @@ flush_error_cb(struct bufferevent *bev, short what, void *arg) what, errcode);
/* It should be impossible to get here with BEV_EVENT_CONNECTED. */ - obfs_assert(what & (BEV_EVENT_EOF|BEV_EVENT_ERROR|BEV_EVENT_TIMEOUT)); obfs_assert(!(what & BEV_EVENT_CONNECTED));
obfs_assert(conn->circuit); @@ -890,7 +887,4 @@ pending_socks_cb(struct bufferevent *bev, short what, void *arg) upstream_read_cb(up->buffer, up); return; } - - /* unknown event code */ - obfs_abort(); } diff --git a/src/util.c b/src/util.c index 3769aba..f56ba58 100644 --- a/src/util.c +++ b/src/util.c @@ -531,12 +531,10 @@ logv(int severity, const char *format, va_list ap) if (logging_method == LOG_METHOD_STDERR) fprintf(stderr, "%s", buf); else if (logging_method == LOG_METHOD_FILE) { - if (!logging_logfile) - abort(); - if (write(logging_logfile, buf, strlen(buf)) < 0) - abort(); + obfs_assert(logging_logfile); + obfs_assert(!(write(logging_logfile, buf, strlen(buf)) < 0)); } else - abort(); + obfs_assert(0); }
/**** Public logging API. ****/