From 80b2cd676dcad1ded843aa7218d0d383a7962c88 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Thu, 14 Feb 2013 00:27:13 +0100 Subject: [PATCH] Don't class-swizzle to call close on super. --- src/SSLSocket.h | 4 ++-- src/SSLSocket.m | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/SSLSocket.h b/src/SSLSocket.h index f321eeb..486e115 100644 --- a/src/SSLSocket.h +++ b/src/SSLSocket.h @@ -43,8 +43,8 @@ - initWithSocket: (OFTCPSocket*)socket privateKeyFile: (OFString*)privateKeyFile certificateFile: (OFString*)certificateFile; -/* Change the return type */ -- (SSLSocket*)accept; +- (void)SSL_super_close; +- (SSLSocket*)accept; /* Changes the return type */ - (void)setPrivateKeyFile: (OFString*)file; - (OFString*)privateKeyFile; - (void)setCertificateFile: (OFString*)file; diff --git a/src/SSLSocket.m b/src/SSLSocket.m index 2f1aed6..95f1ca6 100644 --- a/src/SSLSocket.m +++ b/src/SSLSocket.m @@ -215,11 +215,7 @@ locking_callback(int mode, int n, const char *file, int line) if ((client->_SSL = SSL_new(ctx)) == NULL || !SSL_set_fd(client->_SSL, client->_socket)) { - /* We only want to close the OFTCPSocket */ - object_setClass(client, [OFTCPSocket class]); - [client close]; - object_setClass(client, object_getClass(self)); - + [client SSL_super_close]; @throw [OFAcceptFailedException exceptionWithClass: [self class] socket: self]; } @@ -234,11 +230,7 @@ locking_callback(int mode, int n, const char *file, int line) SSL_FILETYPE_PEM) || !SSL_use_certificate_file(client->_SSL, [_certificateFile cStringWithEncoding: OF_STRING_ENCODING_NATIVE], SSL_FILETYPE_PEM) || SSL_accept(client->_SSL) != 1) { - /* We only want to close the OFTCPSocket */ - object_setClass(client, [OFTCPSocket class]); - [client close]; - object_setClass(client, object_getClass(self)); - + [client SSL_super_close]; @throw [OFAcceptFailedException exceptionWithClass: [self class] socket: self]; } @@ -254,6 +246,11 @@ locking_callback(int mode, int n, const char *file, int line) [super close]; } +- (void)SSL_super_close +{ + [super close]; +} + - (size_t)lowlevelReadIntoBuffer: (void*)buffer length: (size_t)length {