Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0c7b905 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French
Browse files

cifs: clean up length checks in check2ndT2



Thus spake David Howells:

The code that follows this:

  	remaining = total_data_size - data_in_this_rsp;
	if (remaining == 0)
		return 0;
	else if (remaining < 0) {

generates better code if you drop the 'remaining' variable and compare
the values directly.

Clean it up per his recommendation...

Reported-and-acked-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 2b6c26a0
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -248,15 +248,16 @@ static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize)
	total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
	data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);

	remaining = total_data_size - data_in_this_rsp;

	if (remaining == 0)
	if (total_data_size == data_in_this_rsp)
		return 0;
	else if (remaining < 0) {
	else if (total_data_size < data_in_this_rsp) {
		cFYI(1, "total data %d smaller than data in frame %d",
			total_data_size, data_in_this_rsp);
		return -EINVAL;
	} else {
	}

	remaining = total_data_size - data_in_this_rsp;

	cFYI(1, "missing %d bytes from transact2, check next response",
		remaining);
	if (total_data_size > maxBufSize) {
@@ -266,7 +267,6 @@ static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize)
	}
	return remaining;
}
}

static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
{