]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Use generate_nonce_buffer() in smbXsrv_open_global_allocate()
authorVolker Lendecke <vl@samba.org>
Fri, 6 Jan 2023 15:46:11 +0000 (16:46 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 13 Feb 2023 09:53:38 +0000 (09:53 +0000)
We don't need anything cryptographic for persistent file handle ids

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/smbXsrv_open.c

index 585d1ec083810981284cac67589e7f4c0af55a02..c3042978da80a53b23cdb83f3319c2e6b95a1f8a 100644 (file)
@@ -254,13 +254,9 @@ static NTSTATUS smbXsrv_open_global_allocate(
                if (i >= min_tries && last_free != 0) {
                        id = last_free;
                } else {
-                       id = generate_random();
-               }
-               if (id == 0) {
-                       id++;
-               }
-               if (id == UINT32_MAX) {
-                       id--;
+                       generate_nonce_buffer((uint8_t *)&id, sizeof(id));
+                       id = MAX(id, 1);
+                       id = MIN(id, UINT32_MAX-1);
                }
 
                key = smbXsrv_open_global_id_to_key(id, &key_buf);