diff options
author | Matt Johnston <matt@ucc.asn.au> | 2017-05-21 10:48:18 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2017-05-21 10:48:18 +0800 |
commit | 1abd239b9ded3386fac8d553aa4652da88a52d58 (patch) | |
tree | e9a968f2008da99a41b07137ae5e0a4273364faf /fuzz-wrapfd.c | |
parent | 9f1c8b2f8fe1722815af1cfb152c3f48aa9848ce (diff) |
ignore wrapfd_close for unknown
--HG--
branch : fuzz
Diffstat (limited to 'fuzz-wrapfd.c')
-rw-r--r-- | fuzz-wrapfd.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fuzz-wrapfd.c b/fuzz-wrapfd.c index 215eb16..c65ed38 100644 --- a/fuzz-wrapfd.c +++ b/fuzz-wrapfd.c @@ -44,7 +44,6 @@ void wrapfd_add(int fd, buffer *buf, enum wrapfd_mode mode) { 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 @@ void wrapfd_remove(int fd) { 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) { |