Commit 83ffdead authored by Paulo Alcantara's avatar Paulo Alcantara Committed by Steve French

cifs: Fix invalid check in __cifs_calc_signature()

The following check would never evaluate to true:
  > if (i == 0 && iov[0].iov_len <= 4)

Because 'i' always starts at 1.

This patch fixes it and also move the header checks outside the for loop
- which makes more sense.
Signed-off-by: default avatarPaulo Alcantara <palcantara@suse.de>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 35e2cc1b
...@@ -48,26 +48,23 @@ int __cifs_calc_signature(struct smb_rqst *rqst, ...@@ -48,26 +48,23 @@ int __cifs_calc_signature(struct smb_rqst *rqst,
/* iov[0] is actual data and not the rfc1002 length for SMB2+ */ /* iov[0] is actual data and not the rfc1002 length for SMB2+ */
if (is_smb2) { if (is_smb2) {
rc = crypto_shash_update(shash, if (iov[0].iov_len <= 4)
iov[0].iov_base, iov[0].iov_len); return -EIO;
i = 0;
} else { } else {
if (n_vec < 2 || iov[0].iov_len != 4) if (n_vec < 2 || iov[0].iov_len != 4)
return -EIO; return -EIO;
i = 1; /* skip rfc1002 length */
} }
for (i = 1; i < n_vec; i++) { for (; i < n_vec; i++) {
if (iov[i].iov_len == 0) if (iov[i].iov_len == 0)
continue; continue;
if (iov[i].iov_base == NULL) { if (iov[i].iov_base == NULL) {
cifs_dbg(VFS, "null iovec entry\n"); cifs_dbg(VFS, "null iovec entry\n");
return -EIO; return -EIO;
} }
if (is_smb2) {
if (i == 0 && iov[0].iov_len <= 4)
break; /* nothing to sign or corrupt header */
} else
if (i == 1 && iov[1].iov_len <= 4)
break; /* nothing to sign or corrupt header */
rc = crypto_shash_update(shash, rc = crypto_shash_update(shash,
iov[i].iov_base, iov[i].iov_len); iov[i].iov_base, iov[i].iov_len);
if (rc) { if (rc) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment