]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smb2_server: protect against integer wrap with "smb2 max credits = 65535"
authorStefan Metzmacher <metze@samba.org>
Thu, 29 Jan 2015 09:12:30 +0000 (10:12 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 2 Feb 2015 23:04:10 +0000 (00:04 +0100)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=9702

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jan 29 14:58:40 CET 2015 on sn-devel-104

(similar to commit 8aed0fc38ae28cce7fd1a443844a865265fc719c)

Autobuild-User(v4-1-test): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(v4-1-test): Tue Feb  3 00:04:10 CET 2015 on sn-devel-104

source3/smbd/smb2_server.c

index fb99f8d7882fd5202afb50cb7b7c7588a0bf7329..4f3fa15f1de5690988a7058b0fb3cf1ff53a063b 100644 (file)
@@ -797,6 +797,8 @@ static void smb2_set_operation_credit(struct smbd_server_connection *sconn,
                 */
                credits_granted = 0;
        } else {
+               uint16_t additional_possible =
+                       sconn->smb2.max_credits - credit_charge;
                uint16_t additional_max = 0;
                uint16_t additional_credits = credits_requested - 1;
 
@@ -822,6 +824,7 @@ static void smb2_set_operation_credit(struct smbd_server_connection *sconn,
                        break;
                }
 
+               additional_max = MIN(additional_max, additional_possible);
                additional_credits = MIN(additional_credits, additional_max);
 
                credits_granted = credit_charge + additional_credits;