Skip to content

Commit

Permalink
Use correct security level in jni implementation
Browse files Browse the repository at this point in the history
During refactoring, I changed the value of LOGON_DACL from 1 to 2 but
missed the inline usage of this constant. This was easy to miss because
sbt server always uses the jna implementation which was setting the correct
security level. This bug would not likely have been noticed in the sbt
client because the client, which is the only consumer of the jni
implementation, doesn't create named pipes. For this reason, I only
noticed the issue when looking at the commit diff when commenting in
#3.
  • Loading branch information
eatkins committed Jun 20, 2020
1 parent 97bc100 commit df8cff4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
GetLastError()); \
} while (0);

#define LOGON_DACL 2 // must match the value in Win32SecurityLevel.java

static int createSecurityWithDacl(PSECURITY_ATTRIBUTES pSA, DWORD accessMask,
BOOL logon);

Expand All @@ -49,7 +51,7 @@ Java_org_scalasbt_ipcsocket_JNIWin32NamedPipeLibraryProvider_CreateNamedPipeNati
sizeof(SECURITY_ATTRIBUTES))
: NULL;
int err = security ? createSecurityWithDacl(pSA, lpSecurityAttributes,
security == 1)
security == LOGON_DACL)
: 0;
if (!err || !security) {
LPCWSTR name = (LPCWSTR)(*env)->GetStringChars(env, lpName, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public class Win32SecurityLevel {
*/
public static int NO_SECURITY = 0;
public static int OWNER_DACL = 1;
// LOGON_DACL must match the value in JNIWin32NamedPipeLibraryProvider.c
public static int LOGON_DACL = 2;
}
Binary file modified src/main/resources/win32/x86_64/sbtipcsocket.dll
Binary file not shown.

0 comments on commit df8cff4

Please sign in to comment.