Skip to content

Commit bc48814

Browse files
committed
fix(sspi): only add password and domain if they are provided
Users on windows may want to use their local account for authentication, bypassing the need to send a password. In these cases the password must be null, but we were sending a single byte, null-terminated string here because of the use of `std::string`. NODE-1479
1 parent 187aab7 commit bc48814

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/win32/kerberos_sspi.cc

+10-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,16 @@ auth_sspi_client_init(WCHAR* service,
7171
if (*user) {
7272
authIdentity.User = (unsigned short*)user;
7373
authIdentity.UserLength = ulen;
74-
authIdentity.Password = (unsigned short*)password;
75-
authIdentity.PasswordLength = plen;
76-
authIdentity.Domain = (unsigned short*)domain;
77-
authIdentity.DomainLength = dlen;
74+
75+
if (*password) {
76+
authIdentity.Password = (unsigned short*)password;
77+
authIdentity.PasswordLength = plen;
78+
}
79+
80+
if (*domain) {
81+
authIdentity.Domain = (unsigned short*)domain;
82+
authIdentity.DomainLength = dlen;
83+
}
7884

7985
authIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
8086
}

0 commit comments

Comments
 (0)