]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smb2_server: make sure sequence numbers don't wrap at UINT64_MAX
authorStefan Metzmacher <metze@samba.org>
Wed, 27 Jun 2012 13:33:43 +0000 (15:33 +0200)
committerKarolin Seeger <kseeger@samba.org>
Tue, 24 Jul 2012 18:50:16 +0000 (20:50 +0200)
metze
(cherry picked from commit 82dc0b33b9af5094d78f3ecd855900e49c580343)

source3/smbd/smb2_server.c

index 8f7a9a45136b1039cbe15be3e657fc0409e3695f..d983527ea2eef25c678c8f451d0bb86acff08891 100644 (file)
@@ -547,11 +547,26 @@ static void smb2_set_operation_credit(struct smbd_server_connection *sconn,
        }
 
        /*
-        *    remove the range we'll already granted to the client
+        * sequence numbers should not wrap
+        *
+        * 1. calculate the possible credits until
+        *    the sequence numbers start to wrap on 64-bit.
+        *
+        * 2. UINT64_MAX is used for Break Notifications.
+        *
+        * 2. truncate the possible credits to the maximum
+        *    credits we want to grant to the client in total.
+        *
+        * 3. remove the range we'll already granted to the client
         *    this makes sure the client consumes the lowest sequence
         *    number, before we can grant additional credits.
         */
-       credits_possible = sconn->smb2.max_credits;
+       credits_possible = UINT64_MAX - sconn->smb2.seqnum_low;
+       if (credits_possible > 0) {
+               /* remove UINT64_MAX */
+               credits_possible -= 1;
+       }
+       credits_possible = MIN(credits_possible, sconn->smb2.max_credits);
        credits_possible -= sconn->smb2.seqnum_range;
 
        credits_granted = MIN(credits_granted, credits_possible);