@@ -169,6 +169,21 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *server)
169169 }
170170
171171 mid = le64_to_cpu (shdr -> MessageId );
172+ if (check_smb2_hdr (shdr , mid ))
173+ return 1 ;
174+
175+ if (shdr -> StructureSize != SMB2_HEADER_STRUCTURE_SIZE ) {
176+ cifs_dbg (VFS , "Invalid structure size %u\n" ,
177+ le16_to_cpu (shdr -> StructureSize ));
178+ return 1 ;
179+ }
180+
181+ command = le16_to_cpu (shdr -> Command );
182+ if (command >= NUMBER_OF_SMB2_COMMANDS ) {
183+ cifs_dbg (VFS , "Invalid SMB2 command %d\n" , command );
184+ return 1 ;
185+ }
186+
172187 if (len < pdu_size ) {
173188 if ((len >= hdr_size )
174189 && (shdr -> Status != 0 )) {
@@ -189,21 +204,6 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *server)
189204 return 1 ;
190205 }
191206
192- if (check_smb2_hdr (shdr , mid ))
193- return 1 ;
194-
195- if (shdr -> StructureSize != SMB2_HEADER_STRUCTURE_SIZE ) {
196- cifs_dbg (VFS , "Invalid structure size %u\n" ,
197- le16_to_cpu (shdr -> StructureSize ));
198- return 1 ;
199- }
200-
201- command = le16_to_cpu (shdr -> Command );
202- if (command >= NUMBER_OF_SMB2_COMMANDS ) {
203- cifs_dbg (VFS , "Invalid SMB2 command %d\n" , command );
204- return 1 ;
205- }
206-
207207 if (smb2_rsp_struct_sizes [command ] != pdu -> StructureSize2 ) {
208208 if (command != SMB2_OPLOCK_BREAK_HE && (shdr -> Status == 0 ||
209209 pdu -> StructureSize2 != SMB2_ERROR_STRUCTURE_SIZE2_LE )) {
0 commit comments