mirror of
https://github.com/samba-team/samba.git
synced 2025-09-19 13:44:20 +03:00
r6692: used idr_get_new_random() in the nbt client library
(This used to be commit a3f64357af
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
c8177de955
commit
489a6b5591
@@ -367,19 +367,10 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
|
|||||||
|
|
||||||
/* we select a random transaction id unless the user supplied one */
|
/* we select a random transaction id unless the user supplied one */
|
||||||
if (request->name_trn_id == 0) {
|
if (request->name_trn_id == 0) {
|
||||||
request->name_trn_id = generate_random() % UINT16_MAX;
|
id = idr_get_new_random(req->nbtsock->idr, req, UINT16_MAX);
|
||||||
}
|
} else {
|
||||||
|
if (idr_find(req->nbtsock->idr, request->name_trn_id)) goto failed;
|
||||||
/* choose the next available transaction id >= the one asked for.
|
id = idr_get_new_above(req->nbtsock->idr, req, request->name_trn_id,
|
||||||
The strange 2nd call is to try to make the ids less guessable
|
|
||||||
and less likely to collide. It's not possible to make NBT secure
|
|
||||||
to ID guessing, but this at least makes accidential collisions
|
|
||||||
less likely */
|
|
||||||
id = idr_get_new_above(req->nbtsock->idr, req,
|
|
||||||
request->name_trn_id, UINT16_MAX);
|
|
||||||
if (id == -1) {
|
|
||||||
id = idr_get_new_above(req->nbtsock->idr, req,
|
|
||||||
1+(generate_random()%(UINT16_MAX/2)),
|
|
||||||
UINT16_MAX);
|
UINT16_MAX);
|
||||||
}
|
}
|
||||||
if (id == -1) goto failed;
|
if (id == -1) goto failed;
|
||||||
|
Reference in New Issue
Block a user