From 7ce39c17d0d1ecbf8437fd6abf216cff24b16c8f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2015 15:22:30 +0100 Subject: [PATCH] fix it? https://bugzilla.samba.org/show_bug.cgi?id=9702 --- source3/smbd/smb2_server.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index 46bf6f9..3d1e8a9 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -206,7 +206,7 @@ static NTSTATUS smbd_initialize_smb2(struct smbXsrv_connection *xconn) xconn->smb2.credits.seq_low = 0; xconn->smb2.credits.seq_range = 1; xconn->smb2.credits.granted = 1; - xconn->smb2.credits.max = lp_smb2_max_credits(); + xconn->smb2.credits.max = MIN(lp_smb2_max_credits(), INT16_MAX); xconn->smb2.credits.bitmap = bitmap_talloc(xconn, xconn->smb2.credits.max); if (xconn->smb2.credits.bitmap == NULL) { @@ -803,6 +803,7 @@ static void smb2_set_operation_credit(struct smbXsrv_connection *xconn, cmd = SVAL(inhdr, SMB2_HDR_OPCODE); credits_requested = SVAL(inhdr, SMB2_HDR_CREDIT); + credits_requested = MAX(credits_requested, 1); out_flags = IVAL(outhdr, SMB2_HDR_FLAGS); out_status = NT_STATUS(IVAL(outhdr, SMB2_HDR_STATUS)); @@ -821,7 +822,7 @@ static void smb2_set_operation_credit(struct smbXsrv_connection *xconn, * credits on the final response. */ credits_granted = 0; - } else if (credits_requested > 0) { + } else { uint16_t additional_max = 0; uint16_t additional_credits = credits_requested - 1; @@ -850,11 +851,6 @@ static void smb2_set_operation_credit(struct smbXsrv_connection *xconn, additional_credits = MIN(additional_credits, additional_max); credits_granted = credit_charge + additional_credits; - } else if (xconn->smb2.credits.granted == 0) { - /* - * Make sure the client has always at least one credit - */ - credits_granted = 1; } /* -- 1.9.1