vserver 1.9.3
[linux-2.6.git] / fs / cifs / cifsencrypt.c
index 8fdf3d7..1782310 100755 (executable)
@@ -61,7 +61,7 @@ int cifs_sign_smb(struct smb_hdr * cifs_pdu, struct cifsSesInfo * ses,
        if((cifs_pdu == NULL) || (ses == NULL))
                return -EINVAL;
 
-       if((le32_to_cpu(cifs_pdu->Flags2) & SMBFLG2_SECURITY_SIGNATURE) == 0) 
+       if((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) == 0) 
                return rc;
 
        spin_lock(&GlobalMid_Lock);
@@ -107,13 +107,11 @@ int cifs_verify_signature(struct smb_hdr * cifs_pdu, const char * mac_key,
        if(memcmp(cifs_pdu->Signature.SecuritySignature,"BSRSPYL ",8)==0)
                cFYI(1,("dummy signature received for smb command 0x%x",cifs_pdu->Command));
 
-       expected_sequence_number = cpu_to_le32(expected_sequence_number);
-
        /* save off the origiginal signature so we can modify the smb and check
                its signature against what the server sent */
        memcpy(server_response_sig,cifs_pdu->Signature.SecuritySignature,8);
 
-       cifs_pdu->Signature.Sequence.SequenceNumber = expected_sequence_number;
+       cifs_pdu->Signature.Sequence.SequenceNumber = cpu_to_le32(expected_sequence_number);
        cifs_pdu->Signature.Sequence.Reserved = 0;
 
        rc = cifs_calculate_signature(cifs_pdu, mac_key,
@@ -153,7 +151,7 @@ int CalcNTLMv2_partial_mac_key(struct cifsSesInfo * ses, struct nls_table * nls_
        wchar_t * unicode_buf;
        unsigned int i,user_name_len,dom_name_len;
 
-       if(ses)
+       if(ses == NULL)
                return -EINVAL;
 
        E_md4hash(ses->password, temp_hash);
@@ -167,7 +165,13 @@ int CalcNTLMv2_partial_mac_key(struct cifsSesInfo * ses, struct nls_table * nls_
                return -EINVAL;
   
        ucase_buf = kmalloc((MAX_USERNAME_SIZE+1), GFP_KERNEL);
+       if(ucase_buf == NULL)
+               return -ENOMEM;
        unicode_buf = kmalloc((MAX_USERNAME_SIZE+1)*4, GFP_KERNEL);
+       if(unicode_buf == NULL) {
+               kfree(ucase_buf);
+               return -ENOMEM;
+       }
    
        for(i=0;i<user_name_len;i++)
                ucase_buf[i] = nls_info->charset2upper[(int)ses->userName[i]];