svn commit: samba r6692 - in branches/SAMBA_4_0/source/libcli/nbt: .

tridge at samba.org tridge at samba.org
Tue May 10 01:59:33 GMT 2005


Author: tridge
Date: 2005-05-10 01:59:33 +0000 (Tue, 10 May 2005)
New Revision: 6692

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6692

Log:
used idr_get_new_random() in the nbt client library


Modified:
   branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c	2005-05-10 01:59:00 UTC (rev 6691)
+++ branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c	2005-05-10 01:59:33 UTC (rev 6692)
@@ -367,19 +367,10 @@
 
 	/* 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;



More information about the samba-cvs mailing list