@@ -173,6 +173,21 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *server)
173
173
}
174
174
175
175
mid = le64_to_cpu (shdr -> MessageId );
176
+ if (check_smb2_hdr (shdr , mid ))
177
+ return 1 ;
178
+
179
+ if (shdr -> StructureSize != SMB2_HEADER_STRUCTURE_SIZE ) {
180
+ cifs_dbg (VFS , "Invalid structure size %u\n" ,
181
+ le16_to_cpu (shdr -> StructureSize ));
182
+ return 1 ;
183
+ }
184
+
185
+ command = le16_to_cpu (shdr -> Command );
186
+ if (command >= NUMBER_OF_SMB2_COMMANDS ) {
187
+ cifs_dbg (VFS , "Invalid SMB2 command %d\n" , command );
188
+ return 1 ;
189
+ }
190
+
176
191
if (len < pdu_size ) {
177
192
if ((len >= hdr_size )
178
193
&& (shdr -> Status != 0 )) {
@@ -193,21 +208,6 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *server)
193
208
return 1 ;
194
209
}
195
210
196
- if (check_smb2_hdr (shdr , mid ))
197
- return 1 ;
198
-
199
- if (shdr -> StructureSize != SMB2_HEADER_STRUCTURE_SIZE ) {
200
- cifs_dbg (VFS , "Invalid structure size %u\n" ,
201
- le16_to_cpu (shdr -> StructureSize ));
202
- return 1 ;
203
- }
204
-
205
- command = le16_to_cpu (shdr -> Command );
206
- if (command >= NUMBER_OF_SMB2_COMMANDS ) {
207
- cifs_dbg (VFS , "Invalid SMB2 command %d\n" , command );
208
- return 1 ;
209
- }
210
-
211
211
if (smb2_rsp_struct_sizes [command ] != pdu -> StructureSize2 ) {
212
212
if (command != SMB2_OPLOCK_BREAK_HE && (shdr -> Status == 0 ||
213
213
pdu -> StructureSize2 != SMB2_ERROR_STRUCTURE_SIZE2_LE )) {
0 commit comments