Fix for bug #815. Make plaintext unicode passwords work with NT4.x
authorJeremy Allison <jra@samba.org>
Fri, 12 Dec 2003 22:54:43 +0000 (22:54 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 12 Dec 2003 22:54:43 +0000 (22:54 +0000)
Jeremy.
(This used to be commit ba0b5b8c9be9bfeba5e0b3f930ca0463d1e78c9c)

source3/smbd/sesssetup.c

index da48c81fc19cb619a1d54a5556803647d9bd11d0..e9cfa47d0c635692c4db2bbef161cc5474ae51df 100644 (file)
@@ -689,11 +689,17 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,
                        nt_resp = data_blob(p+passlen1, passlen2);
                } else {
                        pstring pass;
-                       BOOL unic;
-                       unic=SVAL(inbuf, smb_flg2) & FLAGS2_UNICODE_STRINGS;
-                       srvstr_pull(inbuf, pass, smb_buf(inbuf), 
-                                   sizeof(pass),  unic ? passlen2 : passlen1, 
-                                   STR_TERMINATE);
+                       BOOL unic=SVAL(inbuf, smb_flg2) & FLAGS2_UNICODE_STRINGS;
+
+                       if ((ra_type == RA_WINNT) && (passlen2 == 0) && unic && passlen1) {
+                               /* NT4.0 stuffs up plaintext unicode password lengths... */
+                               srvstr_pull(inbuf, pass, smb_buf(inbuf) + 1,
+                                       sizeof(pass), passlen1, STR_TERMINATE);
+                       } else {
+                               srvstr_pull(inbuf, pass, smb_buf(inbuf), 
+                                       sizeof(pass),  unic ? passlen2 : passlen1, 
+                                       STR_TERMINATE);
+                       }
                        plaintext_password = data_blob(pass, strlen(pass)+1);
                }