diff options
author | Paulo Alcantara <paulo@paulo.ac> | 2018-06-15 14:58:00 -0400 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2018-06-15 20:17:40 -0400 |
commit | 83ffdeadb46b61580c4c9a5319bd76d258a2963d (patch) | |
tree | a6118338b9763022fb49934c1d27bde6f9e97747 | |
parent | 35e2cc1ba755cf9dbd042e308b2928c868767a98 (diff) |
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: Paulo Alcantara <palcantara@suse.de>
Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r-- | fs/cifs/cifsencrypt.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index f23ff848b158..ee2a8ec70056 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -48,26 +48,23 @@ int __cifs_calc_signature(struct smb_rqst *rqst, | |||
48 | 48 | ||
49 | /* iov[0] is actual data and not the rfc1002 length for SMB2+ */ | 49 | /* iov[0] is actual data and not the rfc1002 length for SMB2+ */ |
50 | if (is_smb2) { | 50 | if (is_smb2) { |
51 | rc = crypto_shash_update(shash, | 51 | if (iov[0].iov_len <= 4) |
52 | iov[0].iov_base, iov[0].iov_len); | 52 | return -EIO; |
53 | i = 0; | ||
53 | } else { | 54 | } else { |
54 | if (n_vec < 2 || iov[0].iov_len != 4) | 55 | if (n_vec < 2 || iov[0].iov_len != 4) |
55 | return -EIO; | 56 | return -EIO; |
57 | i = 1; /* skip rfc1002 length */ | ||
56 | } | 58 | } |
57 | 59 | ||
58 | for (i = 1; i < n_vec; i++) { | 60 | for (; i < n_vec; i++) { |
59 | if (iov[i].iov_len == 0) | 61 | if (iov[i].iov_len == 0) |
60 | continue; | 62 | continue; |
61 | if (iov[i].iov_base == NULL) { | 63 | if (iov[i].iov_base == NULL) { |
62 | cifs_dbg(VFS, "null iovec entry\n"); | 64 | cifs_dbg(VFS, "null iovec entry\n"); |
63 | return -EIO; | 65 | return -EIO; |
64 | } | 66 | } |
65 | if (is_smb2) { | 67 | |
66 | if (i == 0 && iov[0].iov_len <= 4) | ||
67 | break; /* nothing to sign or corrupt header */ | ||
68 | } else | ||
69 | if (i == 1 && iov[1].iov_len <= 4) | ||
70 | break; /* nothing to sign or corrupt header */ | ||
71 | rc = crypto_shash_update(shash, | 68 | rc = crypto_shash_update(shash, |
72 | iov[i].iov_base, iov[i].iov_len); | 69 | iov[i].iov_base, iov[i].iov_len); |
73 | if (rc) { | 70 | if (rc) { |