Don't access isa directly.
This commit is contained in:
parent
edadc4878b
commit
430bde693e
3 changed files with 35 additions and 31 deletions
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
- initWithClass: (Class)class_
|
- initWithClass: (Class)class_
|
||||||
{
|
{
|
||||||
Class c = isa;
|
Class c = [self class];
|
||||||
[self release];
|
[self release];
|
||||||
@throw [OFNotImplementedException exceptionWithClass: c
|
@throw [OFNotImplementedException exceptionWithClass: c
|
||||||
selector: _cmd];
|
selector: _cmd];
|
||||||
|
|
|
@ -131,7 +131,7 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
close(sock);
|
close(sock);
|
||||||
sock = INVALID_SOCKET;
|
sock = INVALID_SOCKET;
|
||||||
@throw [OFInitializationFailedException
|
@throw [OFInitializationFailedException
|
||||||
exceptionWithClass: isa];
|
exceptionWithClass: [self class]];
|
||||||
}
|
}
|
||||||
|
|
||||||
SSL_set_connect_state(ssl);
|
SSL_set_connect_state(ssl);
|
||||||
|
@ -146,7 +146,7 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
close(sock);
|
close(sock);
|
||||||
sock = INVALID_SOCKET;
|
sock = INVALID_SOCKET;
|
||||||
@throw [OFInitializationFailedException
|
@throw [OFInitializationFailedException
|
||||||
exceptionWithClass: isa];
|
exceptionWithClass: [self class]];
|
||||||
}
|
}
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
[self release];
|
[self release];
|
||||||
|
@ -177,7 +177,8 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
|
|
||||||
if ((ssl = SSL_new(ctx)) == NULL || !SSL_set_fd(ssl, sock)) {
|
if ((ssl = SSL_new(ctx)) == NULL || !SSL_set_fd(ssl, sock)) {
|
||||||
[super close];
|
[super close];
|
||||||
@throw [OFConnectionFailedException exceptionWithClass: isa
|
@throw [OFConnectionFailedException
|
||||||
|
exceptionWithClass: [self class]
|
||||||
socket: self
|
socket: self
|
||||||
host: host
|
host: host
|
||||||
port: port];
|
port: port];
|
||||||
|
@ -192,7 +193,8 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
|
cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
|
||||||
SSL_FILETYPE_PEM)) || SSL_connect(ssl) != 1) {
|
SSL_FILETYPE_PEM)) || SSL_connect(ssl) != 1) {
|
||||||
[super close];
|
[super close];
|
||||||
@throw [OFConnectionFailedException exceptionWithClass: isa
|
@throw [OFConnectionFailedException
|
||||||
|
exceptionWithClass: [self class]
|
||||||
socket: self
|
socket: self
|
||||||
host: host
|
host: host
|
||||||
port: port];
|
port: port];
|
||||||
|
@ -206,11 +208,11 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
if ((newSocket->ssl = SSL_new(ctx)) == NULL ||
|
if ((newSocket->ssl = SSL_new(ctx)) == NULL ||
|
||||||
!SSL_set_fd(newSocket->ssl, newSocket->sock)) {
|
!SSL_set_fd(newSocket->ssl, newSocket->sock)) {
|
||||||
/* We only want to close the OFTCPSocket */
|
/* We only want to close the OFTCPSocket */
|
||||||
newSocket->isa = [OFTCPSocket class];
|
object_setClass(newSocket, [OFTCPSocket class]);
|
||||||
[newSocket close];
|
[newSocket close];
|
||||||
newSocket->isa = isa;
|
object_setClass(newSocket, object_getClass(self));
|
||||||
|
|
||||||
@throw [OFAcceptFailedException exceptionWithClass: isa
|
@throw [OFAcceptFailedException exceptionWithClass: [self class]
|
||||||
socket: self];
|
socket: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,11 +224,11 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
[certificateFile cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
|
[certificateFile cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
|
||||||
SSL_FILETYPE_PEM) || SSL_accept(newSocket->ssl) != 1) {
|
SSL_FILETYPE_PEM) || SSL_accept(newSocket->ssl) != 1) {
|
||||||
/* We only want to close the OFTCPSocket */
|
/* We only want to close the OFTCPSocket */
|
||||||
newSocket->isa = [OFTCPSocket class];
|
object_setClass(newSocket, [OFTCPSocket class]);
|
||||||
[newSocket close];
|
[newSocket close];
|
||||||
newSocket->isa = isa;
|
object_setClass(newSocket, object_getClass(self));
|
||||||
|
|
||||||
@throw [OFAcceptFailedException exceptionWithClass: isa
|
@throw [OFAcceptFailedException exceptionWithClass: [self class]
|
||||||
socket: self];
|
socket: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,16 +249,16 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
if (length > INT_MAX)
|
if (length > INT_MAX)
|
||||||
@throw [OFOutOfRangeException exceptionWithClass: isa];
|
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
|
||||||
|
|
||||||
if (sock == INVALID_SOCKET)
|
if (sock == INVALID_SOCKET)
|
||||||
@throw [OFNotConnectedException exceptionWithClass: isa
|
@throw [OFNotConnectedException exceptionWithClass: [self class]
|
||||||
socket: self];
|
socket: self];
|
||||||
|
|
||||||
if (atEndOfStream) {
|
if (atEndOfStream) {
|
||||||
OFReadFailedException *e;
|
OFReadFailedException *e;
|
||||||
|
|
||||||
e = [OFReadFailedException exceptionWithClass: isa
|
e = [OFReadFailedException exceptionWithClass: [self class]
|
||||||
stream: self
|
stream: self
|
||||||
requestedLength: length];
|
requestedLength: length];
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -269,7 +271,7 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = SSL_read(ssl, buffer, (int)length)) < 0)
|
if ((ret = SSL_read(ssl, buffer, (int)length)) < 0)
|
||||||
@throw [OFReadFailedException exceptionWithClass: isa
|
@throw [OFReadFailedException exceptionWithClass: [self class]
|
||||||
stream: self
|
stream: self
|
||||||
requestedLength: length];
|
requestedLength: length];
|
||||||
|
|
||||||
|
@ -283,16 +285,16 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
length: (size_t)length
|
length: (size_t)length
|
||||||
{
|
{
|
||||||
if (length > INT_MAX)
|
if (length > INT_MAX)
|
||||||
@throw [OFOutOfRangeException exceptionWithClass: isa];
|
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
|
||||||
|
|
||||||
if (sock == INVALID_SOCKET)
|
if (sock == INVALID_SOCKET)
|
||||||
@throw [OFNotConnectedException exceptionWithClass: isa
|
@throw [OFNotConnectedException exceptionWithClass: [self class]
|
||||||
socket: self];
|
socket: self];
|
||||||
|
|
||||||
if (atEndOfStream) {
|
if (atEndOfStream) {
|
||||||
OFWriteFailedException *e;
|
OFWriteFailedException *e;
|
||||||
|
|
||||||
e = [OFWriteFailedException exceptionWithClass: isa
|
e = [OFWriteFailedException exceptionWithClass: [self class]
|
||||||
stream: self
|
stream: self
|
||||||
requestedLength: length];
|
requestedLength: length];
|
||||||
|
|
||||||
|
@ -306,7 +308,7 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SSL_write(ssl, buffer, (int)length) < length)
|
if (SSL_write(ssl, buffer, (int)length) < length)
|
||||||
@throw [OFWriteFailedException exceptionWithClass: isa
|
@throw [OFWriteFailedException exceptionWithClass: [self class]
|
||||||
stream: self
|
stream: self
|
||||||
requestedLength: length];
|
requestedLength: length];
|
||||||
}
|
}
|
||||||
|
@ -346,7 +348,8 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
OFDataArray *data;
|
OFDataArray *data;
|
||||||
|
|
||||||
if (![type isEqual: @"tls-unique"])
|
if (![type isEqual: @"tls-unique"])
|
||||||
@throw [OFInvalidArgumentException exceptionWithClass: isa
|
@throw [OFInvalidArgumentException
|
||||||
|
exceptionWithClass: [self class]
|
||||||
selector: _cmd];
|
selector: _cmd];
|
||||||
|
|
||||||
if (SSL_session_reused(ssl) ^ !listening) {
|
if (SSL_session_reused(ssl) ^ !listening) {
|
||||||
|
@ -386,7 +389,7 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
((ret = SSL_get_verify_result(ssl)) != X509_V_OK)) {
|
((ret = SSL_get_verify_result(ssl)) != X509_V_OK)) {
|
||||||
const char *reason = X509_verify_cert_error_string(ret);
|
const char *reason = X509_verify_cert_error_string(ret);
|
||||||
@throw [SSLInvalidCertificateException
|
@throw [SSLInvalidCertificateException
|
||||||
exceptionWithClass: isa
|
exceptionWithClass: [self class]
|
||||||
reason: [OFString
|
reason: [OFString
|
||||||
stringWithUTF8String: reason]];
|
stringWithUTF8String: reason]];
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
[pool release];
|
[pool release];
|
||||||
if (crt == NULL)
|
if (crt == NULL)
|
||||||
@throw [OFInitializationFailedException
|
@throw [OFInitializationFailedException
|
||||||
exceptionWithClass: isa];
|
exceptionWithClass: [self class]];
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
[self release];
|
[self release];
|
||||||
@throw e;
|
@throw e;
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
crt = X509_dup(cert);
|
crt = X509_dup(cert);
|
||||||
if (crt == NULL)
|
if (crt == NULL)
|
||||||
@throw [OFInitializationFailedException
|
@throw [OFInitializationFailedException
|
||||||
exceptionWithClass: isa];
|
exceptionWithClass: [self class]];
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
[self release];
|
[self release];
|
||||||
@throw e;
|
@throw e;
|
||||||
|
@ -418,7 +418,8 @@
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
if (ASN1_STRING_to_UTF8((unsigned char**)&buffer, str) < 0)
|
if (ASN1_STRING_to_UTF8((unsigned char**)&buffer, str) < 0)
|
||||||
@throw [OFInvalidEncodingException exceptionWithClass: isa];
|
@throw [OFInvalidEncodingException
|
||||||
|
exceptionWithClass: [self class]];
|
||||||
|
|
||||||
@try {
|
@try {
|
||||||
ret = [OFString stringWithUTF8String: buffer];
|
ret = [OFString stringWithUTF8String: buffer];
|
||||||
|
|
Reference in a new issue