diff options
-rw-r--r-- | usr.sbin/nsd/nsd-notify.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/nsd-xfer.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/util.c | 6 | ||||
-rw-r--r-- | usr.sbin/nsd/util.h | 5 | ||||
-rw-r--r-- | usr.sbin/nsd/xfrd-tcp.c | 2 |
5 files changed, 14 insertions, 3 deletions
diff --git a/usr.sbin/nsd/nsd-notify.c b/usr.sbin/nsd/nsd-notify.c index 32e1ac874e4..54be9bed91a 100644 --- a/usr.sbin/nsd/nsd-notify.c +++ b/usr.sbin/nsd/nsd-notify.c @@ -330,7 +330,7 @@ main (int argc, char *argv[]) /* Set up the header */ OPCODE_SET(q.packet, OPCODE_NOTIFY); - ID_SET(q.packet, 42); /* Does not need to be random. */ + ID_SET(q.packet, qid_generate()); AA_SET(q.packet); QDCOUNT_SET(q.packet, 1); buffer_skip(q.packet, QHEADERSZ); diff --git a/usr.sbin/nsd/nsd-xfer.c b/usr.sbin/nsd/nsd-xfer.c index a0b8b2d87c9..fa63a13ffa0 100644 --- a/usr.sbin/nsd/nsd-xfer.c +++ b/usr.sbin/nsd/nsd-xfer.c @@ -702,7 +702,7 @@ init_query(query_type *q, uint16_t klass, tsig_record_type *tsig) { - uint16_t query_id = (uint16_t) random(); + uint16_t query_id = qid_generate(); buffer_clear(q->packet); diff --git a/usr.sbin/nsd/util.c b/usr.sbin/nsd/util.c index e19a23a8ac1..b294e8870f6 100644 --- a/usr.sbin/nsd/util.c +++ b/usr.sbin/nsd/util.c @@ -958,3 +958,9 @@ addr2ip( return (0); } + +uint16_t +qid_generate() +{ + return (uint16_t) random(); +} diff --git a/usr.sbin/nsd/util.h b/usr.sbin/nsd/util.h index 37461ae8cb2..eeaf51c7454 100644 --- a/usr.sbin/nsd/util.h +++ b/usr.sbin/nsd/util.h @@ -365,4 +365,9 @@ int addr2ip( #endif , char address[], socklen_t size); +/* + * Generate a random query ID + */ +uint16_t qid_generate(void); + #endif /* _UTIL_H_ */ diff --git a/usr.sbin/nsd/xfrd-tcp.c b/usr.sbin/nsd/xfrd-tcp.c index fd86149b608..f1762cbbcd7 100644 --- a/usr.sbin/nsd/xfrd-tcp.c +++ b/usr.sbin/nsd/xfrd-tcp.c @@ -41,7 +41,7 @@ xfrd_setup_packet(buffer_type* packet, { /* Set up the header */ buffer_clear(packet); - ID_SET(packet, (uint16_t) random()); + ID_SET(packet, qid_generate()); FLAGS_SET(packet, 0); OPCODE_SET(packet, OPCODE_QUERY); QDCOUNT_SET(packet, 1); |