Skip to content

Commit 163bdb9

Browse files
committed
fix(sspi): correct invalid null checks for user data
NODE-1725
1 parent a17ffdb commit 163bdb9

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/win32/kerberos_sspi.cc

+5-9
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ auth_sspi_client_init(WCHAR* service,
6868
return sspi_error_result_with_message("Ran out of memory assigning service");
6969
}
7070

71-
if (user) {
71+
if (*user) {
7272
authIdentity.User = (unsigned short*)user;
7373
authIdentity.UserLength = ulen;
7474
authIdentity.Password = (unsigned short*)password;
@@ -92,7 +92,7 @@ auth_sspi_client_init(WCHAR* service,
9292
/* LogonID (We don't use this) */
9393
NULL,
9494
/* AuthData */
95-
user ? &authIdentity : NULL,
95+
*user ? &authIdentity : NULL,
9696
/* Always NULL */
9797
NULL,
9898
/* Always NULL */
@@ -319,7 +319,7 @@ auth_sspi_client_wrap(sspi_client_state* state,
319319
return sspi_error_result(status, "QueryContextAttributes");
320320
}
321321

322-
if (user) {
322+
if (*user) {
323323
/* Length of user + 4 bytes for security layer (see below). */
324324
plaintextMessageSize = ulen + 4;
325325
} else {
@@ -338,10 +338,10 @@ auth_sspi_client_wrap(sspi_client_state* state,
338338
}
339339

340340
plaintextMessage = inbuf + sizes.cbSecurityTrailer;
341-
if (user) {
341+
if (*user) {
342342
/* Authenticate the provided user. Unlike pykerberos, we don't
343343
* need any information from "data" to do that.
344-
* */
344+
*/
345345
plaintextMessage[0] = 1; /* No security layer */
346346
plaintextMessage[1] = 0;
347347
plaintextMessage[2] = 0;
@@ -488,7 +488,6 @@ base64_encode(const SEC_CHAR* value, DWORD vlen) {
488488
}
489489
}
490490

491-
// PyErr_Format(GSSError, "CryptBinaryToString failed.");
492491
return NULL;
493492
}
494493

@@ -537,7 +536,6 @@ wide_to_utf8(WCHAR* value) {
537536
if (len) {
538537
out = (CHAR*)malloc(sizeof(CHAR) * len);
539538
if (!out) {
540-
// PyErr_SetNone(PyExc_MemoryError);
541539
return NULL;
542540
}
543541

@@ -555,7 +553,5 @@ wide_to_utf8(WCHAR* value) {
555553
}
556554
}
557555

558-
// set_gsserror(GetLastError(), "WideCharToMultiByte");
559556
return NULL;
560557
}
561-

src/win32/kerberos_win32.cc

-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ NAN_METHOD(InitializeClient) {
170170
worker->Call(2, argv);
171171
});
172172
});
173-
174-
175173
}
176174

177175
NAN_METHOD(InitializeServer) {

0 commit comments

Comments
 (0)