changeset 1360:16f45f2df38f fuzz

ignore wrapfd_close for unknown
author Matt Johnston <matt@ucc.asn.au>
date Sun, 21 May 2017 10:48:18 +0800
parents 665dd8957a67
children f9f930e1a516
files fuzz-wrapfd.c fuzz-wrapfd.h
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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) {
--- 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