ignore wrapfd_close for unknown

--HG--
branch : fuzz
This commit is contained in:
Matt Johnston 2017-05-21 10:48:18 +08:00
parent 9f1c8b2f8f
commit 1abd239b9d
2 changed files with 10 additions and 3 deletions

View File

@ -44,7 +44,6 @@ void wrapfd_add(int fd, buffer *buf, enum wrapfd_mode mode) {
assert(wrap_fds[fd].mode == UNUSED); assert(wrap_fds[fd].mode == UNUSED);
assert(buf || mode == RANDOMIN); assert(buf || mode == RANDOMIN);
wrap_fds[fd].mode = mode; wrap_fds[fd].mode = mode;
wrap_fds[fd].buf = buf; wrap_fds[fd].buf = buf;
wrap_fds[fd].closein = 0; wrap_fds[fd].closein = 0;
@ -73,8 +72,15 @@ void wrapfd_remove(int fd) {
nused--; nused--;
} }
void wrapfd_close(int fd) { int wrapfd_close(int fd) {
wrapfd_remove(fd); if (fd >= 0 && fd <= IOWRAP_MAXFD && wrap_fds[fd].mode != UNUSED)
{
wrapfd_remove(fd);
return 0;
}
else {
return close(fd);
}
} }
int wrapfd_read(int fd, void *out, size_t count) { int wrapfd_read(int fd, void *out, size_t count) {

View File

@ -19,5 +19,6 @@ int wrapfd_read(int fd, void *out, size_t count);
int wrapfd_write(int fd, const void* in, size_t count); int wrapfd_write(int fd, const void* in, size_t count);
int wrapfd_select(int nfds, fd_set *readfds, fd_set *writefds, int wrapfd_select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout); fd_set *exceptfds, struct timeval *timeout);
int wrapfd_close(int fd);
#endif // FUZZ_WRAPFD_H #endif // FUZZ_WRAPFD_H