# HG changeset patch # User Matt Johnston # Date 1495334898 -28800 # Node ID 16f45f2df38f18bdbd0fdbc99d83d3e9dc560bff # Parent 665dd8957a67c93c3fe5964b79710491769a3585 ignore wrapfd_close for unknown diff -r 665dd8957a67 -r 16f45f2df38f fuzz-wrapfd.c --- a/fuzz-wrapfd.c Sat May 20 23:39:01 2017 +0800 +++ b/fuzz-wrapfd.c Sun May 21 10:48:18 2017 +0800 @@ -44,7 +44,6 @@ assert(wrap_fds[fd].mode == UNUSED); assert(buf || mode == RANDOMIN); - wrap_fds[fd].mode = mode; wrap_fds[fd].buf = buf; wrap_fds[fd].closein = 0; @@ -73,8 +72,15 @@ nused--; } -void wrapfd_close(int fd) { - wrapfd_remove(fd); +int wrapfd_close(int 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) { diff -r 665dd8957a67 -r 16f45f2df38f fuzz-wrapfd.h --- a/fuzz-wrapfd.h Sat May 20 23:39:01 2017 +0800 +++ b/fuzz-wrapfd.h Sun May 21 10:48:18 2017 +0800 @@ -19,5 +19,6 @@ int wrapfd_write(int fd, const void* in, size_t count); int wrapfd_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); +int wrapfd_close(int fd); #endif // FUZZ_WRAPFD_H