diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2007-03-21 12:26:38 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2007-03-21 12:26:38 +0000 |
commit | 2daa434f700577c55beab0ab31f6c4bec7b2e9d9 (patch) | |
tree | 0f9e03065801f39629a04948233d66ccbeb01410 | |
parent | c0ead9feddf77d5dad992432507591a2ac5faff9 (diff) |
Use arc4random() to generate random IDs. In the future we
may want to consider using res_randomid() but since evdns.c
checks for duplicates this is not strictly necessary.
-rw-r--r-- | lib/libevent/Makefile | 4 | ||||
-rw-r--r-- | lib/libevent/evdns.c | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/libevent/Makefile b/lib/libevent/Makefile index 7aa87a091b6..e828a2e4447 100644 --- a/lib/libevent/Makefile +++ b/lib/libevent/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.24 2007/03/21 12:22:30 millert Exp $ +# $OpenBSD: Makefile,v 1.25 2007/03/21 12:26:36 millert Exp $ LIB= event WANTLINT= @@ -35,7 +35,7 @@ MLINKS= event.3 event_init.3 event.3 event_dispatch.3 event.3 event_loop.3 \ evdns.3 evdns_set_log_fn.3 CFLAGS+= -I${.CURDIR} -DNDEBUG \ - -DDNS_USE_CPU_CLOCK_FOR_ID \ + -DDNS_USE_ARC4RANDOM_FOR_ID \ -DHAVE_CLOCK_GETTIME \ -DHAVE_CLOCK_MONOTONIC \ -DHAVE_FCNTL_H \ diff --git a/lib/libevent/evdns.c b/lib/libevent/evdns.c index f50e6f42132..6c342a786d4 100644 --- a/lib/libevent/evdns.c +++ b/lib/libevent/evdns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evdns.c,v 1.1 2007/03/19 15:12:49 millert Exp $ */ +/* $OpenBSD: evdns.c,v 1.2 2007/03/21 12:26:37 millert Exp $ */ /* The original version of this module was written by Adam Langley; for * a history of modifications, check out the subversion logs. @@ -46,11 +46,13 @@ #ifndef DNS_USE_CPU_CLOCK_FOR_ID #ifndef DNS_USE_GETTIMEOFDAY_FOR_ID #ifndef DNS_USE_OPENSSL_FOR_ID +#ifndef DNS_USE_ARC4RANDOM_FOR_ID #error Must configure at least one id generation method. #error Please see the documentation. #endif #endif #endif +#endif // #define _POSIX_C_SOURCE 200507 #define _GNU_SOURCE @@ -1031,6 +1033,11 @@ transaction_id_pick(void) { } #endif +#ifdef DNS_USE_ARC4RANDOM_FOR_ID + u16 trans_id; + trans_id = arc4random() & 0xffff; +#endif + if (trans_id == 0xffff) continue; // now check to see if that id is already inflight req = started_at = req_head; |