diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2016-03-05 19:18:07 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2016-03-05 19:18:07 +0000 |
| commit | 5bcd892e61c20957144a1786050eaecd6a8ad94e (patch) | |
| tree | 36ee205d83b0e684b78dc69ccfeb27bcf0521aea /testcode | |
| parent | e24c5f9706c7df9bbd9a49f3a6d2dddb9e80b480 (diff) | |
Diffstat (limited to 'testcode')
| -rw-r--r-- | testcode/asynclook.c | 5 | ||||
| -rw-r--r-- | testcode/delayer.c | 5 | ||||
| -rw-r--r-- | testcode/fake_event.c | 1 | ||||
| -rw-r--r-- | testcode/replay.c | 3 | ||||
| -rw-r--r-- | testcode/streamtcp.c | 2 | ||||
| -rw-r--r-- | testcode/testbound.c | 2 |
6 files changed, 11 insertions, 7 deletions
diff --git a/testcode/asynclook.c b/testcode/asynclook.c index 534489735bb2..43e1dccf5b78 100644 --- a/testcode/asynclook.c +++ b/testcode/asynclook.c @@ -335,12 +335,17 @@ ext_thread(void* arg) r = ub_wait(inf->ctx); checkerr("ub_ctx_wait", r); } + /* if these locks are destroyed, or if the async_ids is freed, then + a use-after-free happens in another thread. + The allocation is only part of this test, though. */ + /* if(async_ids) { for(i=0; i<inf->numq; i++) { lock_basic_destroy(&async_ids[i].lock); } } free(async_ids); + */ return NULL; } diff --git a/testcode/delayer.c b/testcode/delayer.c index 050cbd23e759..5489b591e337 100644 --- a/testcode/delayer.c +++ b/testcode/delayer.c @@ -1042,7 +1042,7 @@ service(const char* bind_str, int bindport, const char* serv_str, } i=0; if(bindport == 0) { - bindport = 1024 + random()%64000; + bindport = 1024 + arc4random()%64000; i = 100; } while(1) { @@ -1058,7 +1058,7 @@ service(const char* bind_str, int bindport, const char* serv_str, #endif if(i--==0) fatal_exit("cannot bind any port"); - bindport = 1024 + random()%64000; + bindport = 1024 + arc4random()%64000; } else break; } fd_set_nonblock(s); @@ -1138,7 +1138,6 @@ int main(int argc, char** argv) verbosity = 0; log_init(0, 0, 0); log_ident_set("delayer"); - srandom(time(NULL) ^ getpid()); if(argc == 1) usage(argv); while( (c=getopt(argc, argv, "b:d:f:hm:p:")) != -1) { switch(c) { diff --git a/testcode/fake_event.c b/testcode/fake_event.c index e371cfdaabcd..e1bec24d1a38 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -900,6 +900,7 @@ outside_network_create(struct comm_base* base, size_t bufsize, struct ub_randstate* ATTR_UNUSED(rnd), int ATTR_UNUSED(use_caps_for_id), int* ATTR_UNUSED(availports), int ATTR_UNUSED(numavailports), size_t ATTR_UNUSED(unwanted_threshold), + int ATTR_UNUSED(outgoing_tcp_mss), void (*unwanted_action)(void*), void* ATTR_UNUSED(unwanted_param), int ATTR_UNUSED(do_udp), void* ATTR_UNUSED(sslctx), int ATTR_UNUSED(delayclose), struct dt_env* ATTR_UNUSED(dtenv)) diff --git a/testcode/replay.c b/testcode/replay.c index 8a88814e765a..22670eb93276 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -499,8 +499,7 @@ replay_scenario_delete(struct replay_scenario* scen) struct replay_range* rng, *rngn; if(!scen) return; - if(scen->title) - free(scen->title); + free(scen->title); mom = scen->mom_first; while(mom) { momn = mom->mom_next; diff --git a/testcode/streamtcp.c b/testcode/streamtcp.c index c5919428a52e..b78506beb5df 100644 --- a/testcode/streamtcp.c +++ b/testcode/streamtcp.c @@ -265,7 +265,7 @@ static int get_random(void) if (RAND_bytes((unsigned char*)&r, (int)sizeof(r)) == 1) { return r; } - return (int)random(); + return arc4random(); } /** send the TCP queries and print answers */ diff --git a/testcode/testbound.c b/testcode/testbound.c index d908150a017b..674b39ac8942 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -142,7 +142,7 @@ spool_auto_file(FILE* in, int* lineno, FILE* cfg, char* id) /* find filename for new file */ while(isspace((unsigned char)*id)) id++; - if(strlen(id)==0) + if(*id == '\0') fatal_exit("AUTROTRUST_FILE must have id, line %d", *lineno); id[strlen(id)-1]=0; /* remove newline */ fake_temp_file("_auto_", id, line, sizeof(line)); |
