summaryrefslogtreecommitdiff
path: root/bufferevent_openssl.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-11-24 12:31:50 -0500
committerNick Mathewson <nickm@torproject.org>2011-11-24 12:31:50 -0500
commitf3b89dec9eac2cf4000c8dc9467abdbf27121674 (patch)
tree28034d7040327542a5367eb37d7578193b43e17f /bufferevent_openssl.c
parenta44cd2b0205dfa5c5ffaf8b5a41f9d9a625054ba (diff)
downloadlibevent-f3b89dec9eac2cf4000c8dc9467abdbf27121674.tar.gz
Fix two issues in the allow_dirty_shutdown code.
First, it shouldn't crash when it's passed a non-ssl bufferevent. Second, it should behave correctly when it gets a true argument other than 1.
Diffstat (limited to 'bufferevent_openssl.c')
-rw-r--r--bufferevent_openssl.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/bufferevent_openssl.c b/bufferevent_openssl.c
index 6f131598..fc6e9577 100644
--- a/bufferevent_openssl.c
+++ b/bufferevent_openssl.c
@@ -1389,24 +1389,28 @@ bufferevent_openssl_socket_new(struct event_base *base,
base, NULL, fd, ssl, state, options);
}
-int bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev)
+int
+bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev)
{
- int allow_dirty_shutdown = 0;
+ int allow_dirty_shutdown = -1;
struct bufferevent_openssl *bev_ssl;
BEV_LOCK(bev);
bev_ssl = upcast(bev);
- allow_dirty_shutdown = bev_ssl->allow_dirty_shutdown;
+ if (bev_ssl)
+ allow_dirty_shutdown = bev_ssl->allow_dirty_shutdown;
BEV_UNLOCK(bev);
return allow_dirty_shutdown;
}
-void bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev,
+void
+bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev,
int allow_dirty_shutdown)
{
struct bufferevent_openssl *bev_ssl;
BEV_LOCK(bev);
bev_ssl = upcast(bev);
- bev_ssl->allow_dirty_shutdown = allow_dirty_shutdown;
+ if (bev_ssl)
+ bev_ssl->allow_dirty_shutdown = !!allow_dirty_shutdown;
BEV_UNLOCK(bev);
}