From df8cff4be331b59e67cc5febbcaed57882bcaf36 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sat, 20 Jun 2020 12:49:09 -0700 Subject: [PATCH] Use correct security level in jni implementation 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 https://github.com/sbt/ipcsocket/pull/3. --- ...csocket_JNIWin32NamedPipeLibraryProvider.c | 4 +++- .../ipcsocket/Win32SecurityLevel.java | 1 + .../resources/win32/x86_64/sbtipcsocket.dll | Bin 331648 -> 331648 bytes 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/jni/org_scalasbt_ipcsocket_JNIWin32NamedPipeLibraryProvider.c b/jni/org_scalasbt_ipcsocket_JNIWin32NamedPipeLibraryProvider.c index dc6afeb..57267a2 100644 --- a/jni/org_scalasbt_ipcsocket_JNIWin32NamedPipeLibraryProvider.c +++ b/jni/org_scalasbt_ipcsocket_JNIWin32NamedPipeLibraryProvider.c @@ -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); @@ -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); diff --git a/src/main/java/org/scalasbt/ipcsocket/Win32SecurityLevel.java b/src/main/java/org/scalasbt/ipcsocket/Win32SecurityLevel.java index c55e6e8..de47c7c 100644 --- a/src/main/java/org/scalasbt/ipcsocket/Win32SecurityLevel.java +++ b/src/main/java/org/scalasbt/ipcsocket/Win32SecurityLevel.java @@ -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; } diff --git a/src/main/resources/win32/x86_64/sbtipcsocket.dll b/src/main/resources/win32/x86_64/sbtipcsocket.dll index 8686504a83c0bbae80324aeac16da347c43522a9..356380c67591ed089cf6fa8da9e51ff6e87ee4cb 100755 GIT binary patch delta 54 zcmZpeFVZkyWI_kCN9MbU-M&o04>sQF;$mdloXS1l4kXyj?$yrj#R$YqK+L?I-HWC2 FC;&k`6E6S& delta 54 zcmZpeFVZkyWI_k?alN+_yM3AbvNzu9;$mdnoXS1l4kXyj?$yrj#R$YqK+L?I-HWC2 FC;&nK6FL9@