mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-16 07:45:23 -04:00
Fix a bug that could allow dns requests with duplicate tx ids
Spotted by Marko Kreen
This commit is contained in:
parent
1d6e30e6f8
commit
e50ba5b61b
14
evdns.c
14
evdns.c
@ -1108,20 +1108,12 @@ evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void))
|
|||||||
static u16
|
static u16
|
||||||
transaction_id_pick(void) {
|
transaction_id_pick(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const struct request *req = req_head, *started_at;
|
|
||||||
u16 trans_id = trans_id_function();
|
u16 trans_id = trans_id_function();
|
||||||
|
|
||||||
if (trans_id == 0xffff) continue;
|
if (trans_id == 0xffff) continue;
|
||||||
/* now check to see if that id is already inflight */
|
|
||||||
req = started_at = req_head;
|
if (request_find_from_trans_id(trans_id) == NULL)
|
||||||
if (req) {
|
return trans_id;
|
||||||
do {
|
|
||||||
if (req->trans_id == trans_id) break;
|
|
||||||
req = req->next;
|
|
||||||
} while (req != started_at);
|
|
||||||
}
|
|
||||||
/* we didn't find it, so this is a good id */
|
|
||||||
if (req == started_at) return trans_id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user