ext4: fix sleep inside spinlock issue with quota and dealloc (#14739)
[safe/jmp/linux-2.6] / fs / cifs / smbencrypt.c
index 1966ada..93fb09a 100644 (file)
@@ -7,17 +7,17 @@
    Modified by Jeremy Allison 1995.
    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2002-2003
    Modified by Steve French (sfrench@us.ibm.com) 2002-2003
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #include "cifs_debug.h"
 #include "cifsencrypt.h"
 
-#ifndef FALSE
-#define FALSE 0
+#ifndef false
+#define false 0
 #endif
-#ifndef TRUE
-#define TRUE 1
+#ifndef true
+#define true 1
 #endif
 
 /* following came from the other byteorder.h to avoid include conflicts */
 
 /*The following definitions come from  libsmb/smbencrypt.c  */
 
-void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
+void SMBencrypt(unsigned char *passwd, const unsigned char *c8,
+               unsigned char *p24);
 void E_md4hash(const unsigned char *passwd, unsigned char *p16);
-static void SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8,
+static void SMBOWFencrypt(unsigned char passwd[16], const unsigned char *c8,
                   unsigned char p24[24]);
 void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
 
@@ -61,7 +62,7 @@ void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
    encrypted password into p24 */
 /* Note that password must be uppercased and null terminated */
 void
-SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
+SMBencrypt(unsigned char *passwd, const unsigned char *c8, unsigned char *p24)
 {
        unsigned char p14[15], p21[21];
 
@@ -73,14 +74,14 @@ SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
        E_P16(p14, p21);
 
        SMBOWFencrypt(p21, c8, p24);
-       
+
        memset(p14, 0, 15);
        memset(p21, 0, 21);
 }
 
 /* Routines for Windows NT MD4 Hash functions. */
 static int
-_my_wcslen(__u16 * str)
+_my_wcslen(__u16 *str)
 {
        int len = 0;
        while (*str++ != 0)
@@ -96,7 +97,7 @@ _my_wcslen(__u16 * str)
  */
 
 static int
-_my_mbstowcs(__u16 * dst, const unsigned char *src, int len)
+_my_mbstowcs(__u16 *dst, const unsigned char *src, int len)
 {      /* BB not a very good conversion routine - change/fix */
        int i;
        __u16 val;
@@ -125,9 +126,9 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
        /* Password cannot be longer than 128 characters */
        if (passwd) {
                len = strlen((char *) passwd);
-               if (len > 128) {
+               if (len > 128)
                        len = 128;
-               }
+
                /* Password must be converted to NT unicode */
                _my_mbstowcs(wpwd, passwd, len);
        } else
@@ -135,7 +136,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
 
        wpwd[len] = 0;  /* Ensure string is null terminated */
        /* Calculate length in bytes */
-       len = _my_wcslen(wpwd) * sizeof (__u16);
+       len = _my_wcslen(wpwd) * sizeof(__u16);
 
        mdfour(p16, (unsigned char *) wpwd, len);
        memset(wpwd, 0, 129 * 2);
@@ -167,7 +168,7 @@ nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16])
        E_P16((unsigned char *) passwd, (unsigned char *) p16);
 
        /* clear out local copy of user's password (just being paranoid). */
-       memset(passwd, '\0', sizeof (passwd));
+       memset(passwd, '\0', sizeof(passwd));
 }
 #endif
 
@@ -178,8 +179,8 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
                const char *domain_n, unsigned char kr_buf[16],
                const struct nls_table *nls_codepage)
 {
-       wchar_t * user_u;
-       wchar_t * dom_u;
+       wchar_t *user_u;
+       wchar_t *dom_u;
        int user_l, domain_l;
        struct HMACMD5Context ctx;
 
@@ -188,9 +189,11 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
        if (user_u == NULL)
                return;
        dom_u = user_u + 1024;
-    
-       /* push_ucs2(NULL, user_u, user_n, (user_l+1)*2, STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER);
-          push_ucs2(NULL, dom_u, domain_n, (domain_l+1)*2, STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER); */
+
+       /* push_ucs2(NULL, user_u, user_n, (user_l+1)*2,
+                       STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER);
+          push_ucs2(NULL, dom_u, domain_n, (domain_l+1)*2,
+                       STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER); */
 
        /* BB user and domain may need to be uppercased */
        user_l = cifs_strtoUCS(user_u, user_n, 511, nls_codepage);
@@ -210,7 +213,7 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
 
 /* Does the des encryption from the NT or LM MD4 hash. */
 static void
-SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8,
+SMBOWFencrypt(unsigned char passwd[16], const unsigned char *c8,
              unsigned char p24[24])
 {
        unsigned char p21[21];