nbt bug?

Stefan (metze) Metzmacher metze at samba.org
Fri Jan 21 17:59:48 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi tridge,

I think to reset the name_trn_id when we store it under an other id in the idr-tree
otherwise the reply couldn't be matches correctly.


	/* we select a random transaction id unless the user supplied one */
	if (req->request->name_trn_id == 0) {
		req->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,
			       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);
+		req->request->name_trn_id = 1+(generate_random()%(UINT16_MAX/2);
+		id = idr_get_new_above(req->nbtsock->idr, req,
+				       req->request->name_trn_id, UINT16_MAX);
	}
	if (id == -1) goto failed;


- --
metze

Stefan Metzmacher <metze at samba.org> www.samba.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3-nr1 (Windows XP)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB8UMUm70gjA5TCD8RAoawAKCBB+0yFwYaE7pHlOxdI4DI0mBrBgCgiHhu
TxIAhTf08xSh7Y2tE4ozrAM=
=e9eZ
-----END PGP SIGNATURE-----


More information about the samba-technical mailing list