Skip to content

Commit 5fa2cff

Browse files
committed
smb3: check xattr value length earlier
Coverity complains about assigning a pointer based on value length before checking that value length goes beyond the end of the SMB. Although this is even more unlikely as value length is a single byte, and the pointer is not dereferenced until laterm, it is clearer to check the lengths first. Addresses-Coverity: 1467704 ("Speculative execution data leak") Reviewed-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 3d7cb6b commit 5fa2cff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/cifs/smb2ops.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,9 +1145,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
11451145
size_t name_len, value_len, user_name_len;
11461146

11471147
while (src_size > 0) {
1148-
name = &src->ea_data[0];
11491148
name_len = (size_t)src->ea_name_length;
1150-
value = &src->ea_data[src->ea_name_length + 1];
11511149
value_len = (size_t)le16_to_cpu(src->ea_value_length);
11521150

11531151
if (name_len == 0)
@@ -1159,6 +1157,9 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
11591157
goto out;
11601158
}
11611159

1160+
name = &src->ea_data[0];
1161+
value = &src->ea_data[src->ea_name_length + 1];
1162+
11621163
if (ea_name) {
11631164
if (ea_name_len == name_len &&
11641165
memcmp(ea_name, name, name_len) == 0) {

0 commit comments

Comments
 (0)