@@ -60,13 +60,14 @@ _maxFD = (int)_cancelFD[0]; return self; } -- (void)OF_addObjectForReading: (id)object - fileDescriptor: (int)fd +- (void)OF_addObjectForReading: (id )object { + int fd = [object fileDescriptorForReading]; + if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; #ifndef _WIN32 if (fd >= FD_SETSIZE) @@ -77,13 +78,14 @@ _maxFD = fd; FD_SET(fd, &_readFDs); } -- (void)OF_addObjectForWriting: (id)object - fileDescriptor: (int)fd +- (void)OF_addObjectForWriting: (id )object { + int fd = [object fileDescriptorForWriting]; + if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; #ifndef _WIN32 if (fd >= FD_SETSIZE) @@ -94,14 +96,15 @@ _maxFD = fd; FD_SET(fd, &_writeFDs); } -- (void)OF_removeObjectForReading: (id)object - fileDescriptor: (int)fd +- (void)OF_removeObjectForReading: (id )object { /* TODO: Adjust _maxFD */ + + int fd = [object fileDescriptorForReading]; if (fd < 0) @throw [OFOutOfRangeException exception]; #ifndef _WIN32 @@ -110,14 +113,15 @@ #endif FD_CLR(fd, &_readFDs); } -- (void)OF_removeObjectForWriting: (id)object - fileDescriptor: (int)fd +- (void)OF_removeObjectForWriting: (id )object { /* TODO: Adjust _maxFD */ + + int fd = [object fileDescriptorForWriting]; if (fd < 0) @throw [OFOutOfRangeException exception]; #ifndef _WIN32