@@ -62,13 +62,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 OF_WINDOWS if (fd >= FD_SETSIZE) @@ -79,13 +80,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 OF_WINDOWS if (fd >= FD_SETSIZE) @@ -96,14 +98,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 OF_WINDOWS @@ -112,14 +115,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 OF_WINDOWS