summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <2185596822@qq.com>2020-05-26 06:45:13 +0800
committerunknown <2185596822@qq.com>2020-05-26 06:45:13 +0800
commit3b32a7d2eb8c48999309b12bd7a3a7200544eb77 (patch)
tree9126ddba6980d527223636f628bd44cfab36e83c
parentd083bf81eb1c8a3b2dd702def5281afa5a7f74d2 (diff)
downloadhonggfuzz-3b32a7d2eb8c48999309b12bd7a3a7200544eb77.tar.gz
add chose when tcp server not return anything
-rw-r--r--libhfnetdriver/netdriver.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libhfnetdriver/netdriver.c b/libhfnetdriver/netdriver.c
index 0549eeea..5e6cc2be 100644
--- a/libhfnetdriver/netdriver.c
+++ b/libhfnetdriver/netdriver.c
@@ -32,7 +32,7 @@ const char *const LIBHFNETDRIVER_module_netdriver = _HF_NETDRIVER_SIG;
#define HFND_TCP_PORT_ENV "HFND_TCP_PORT"
#define HFND_SOCK_PATH_ENV "HFND_SOCK_PATH"
#define HFND_SKIP_FUZZING_ENV "HFND_SKIP_FUZZING"
-
+//# define NORECVTIME 10
static char *initial_server_argv[] = {"fuzzer", NULL};
static struct {
@@ -436,9 +436,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
* TCP server to drop the input data, instead of processing it. Use BSS to avoid putting
* pressure on the stack size
*/
+#ifdef NORECVTIME
+ struct timeval timeout={1,0};//1s
+ setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,&timeout,sizeof(timeout));
+ clock_t start,end;
+ start = clock();
+#endif
static char b[1024ULL * 1024ULL * 4ULL];
- while (TEMP_FAILURE_RETRY(recv(sock, b, sizeof(b), MSG_WAITALL)) > 0)
- ;
+ while (TEMP_FAILURE_RETRY(recv(sock, b, sizeof(b), MSG_WAITALL)) > 0){
+#ifdef NORECVTIME
+ end= clock();
+ if( ((double)end-start)/CLK_TCK>NORECVTIME)
+ break;
+#endif
+ }
close(sock);