summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-10 01:59:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:16:35 -0500
commit489a6b5591c37a8977426d9ca7fd07978e5e5614 (patch)
treeb566657c5b3d39a70e95f36add757310f3011664
parentc8177de955ca1aa8683ef73b0e5a0018fbca2707 (diff)
downloadsamba-489a6b5591c37a8977426d9ca7fd07978e5e5614.tar.gz
samba-489a6b5591c37a8977426d9ca7fd07978e5e5614.tar.bz2
samba-489a6b5591c37a8977426d9ca7fd07978e5e5614.zip
r6692: used idr_get_new_random() in the nbt client library
(This used to be commit a3f64357af75587a855cfedb58ce2583658c7d04)
-rw-r--r--source4/libcli/nbt/nbtsocket.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 1d8cf36ea4..481327cc85 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -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 */
if (request->name_trn_id == 0) {
- request->name_trn_id = generate_random() % UINT16_MAX;
- }
-
- /* choose the next available transaction id >= the one asked for.
- 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)),
+ id = idr_get_new_random(req->nbtsock->idr, req, UINT16_MAX);
+ } else {
+ if (idr_find(req->nbtsock->idr, request->name_trn_id)) goto failed;
+ id = idr_get_new_above(req->nbtsock->idr, req, request->name_trn_id,
UINT16_MAX);
}
if (id == -1) goto failed;