Skip to content

Commit

Permalink
Merge pull request #120 from splunk/bugfix/DVPL-7245
Browse files Browse the repository at this point in the history
Fix splunk restart issue (Jo Horsnby fixed identified the problem).
  • Loading branch information
shakeelmohamed authored Mar 1, 2018
2 parents 825fa93 + 05434e4 commit 75f0337
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Binary file modified launchers/shim-windows_x86.exe
Binary file not shown.
Binary file modified launchers/shim-windows_x86_64.exe
Binary file not shown.
14 changes: 6 additions & 8 deletions launchers/shim/shim/shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ int _tmain(int argc, _TCHAR* argv[])
HANDLE &jvmHandle = processHandles[1];
HANDLE ghJob = NULL;
PTSTR customizedJavaCmd = NULL, jarPath = NULL, jvmOptions = NULL, jvmCommandLine = NULL;
DWORD waitOutcome, exitCode;

DWORD waitOutcome;
DWORD returnCode = 0;

STARTUPINFO si;
Expand Down Expand Up @@ -74,7 +73,7 @@ int _tmain(int argc, _TCHAR* argv[])
jvmOptions = readJvmOptions(jarPath);
jvmCommandLine = assembleJvmCommand(customizedJavaCmd, jarPath, jvmOptions, argc, argv);

if (!CreateProcess(NULL, jvmCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
if (!CreateProcess(NULL, jvmCommandLine, NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) {
// Process creation failed.
printErrorMessage(GetLastError(), jvmCommandLine);

Expand Down Expand Up @@ -155,7 +154,7 @@ void printErrorMessage(DWORD errorCode, ...) {


PTSTR readJvmOptions(PTSTR jarPath) {
DWORD jarPathLen = _tcslen(jarPath);
size_t jarPathLen = _tcslen(jarPath);
// vmoptsPath is the same as jarPath, but ending with .vmopts instead of .jar. We allocate
// 3 additional TCHARs for the additional length of .vmopts, and 1 more TCHAR for a NULL
// terminator, so jarPathLen+4.
Expand Down Expand Up @@ -297,7 +296,7 @@ PTSTR getPathToJar() {
PCTSTR jarSuffix = TEXT(".jar");
const DWORD jarSuffixLen = 5;
const size_t N = 1024;
DWORD baseNameLen;
size_t baseNameLen;

thisPath = (PTSTR)malloc(N*sizeof(TCHAR));
if (N == GetModuleFileName(NULL, thisPath, N) && ERROR_INSUFFICIENT_BUFFER == GetLastError()) {
Expand Down Expand Up @@ -325,7 +324,7 @@ PTSTR getPathToJar() {
*endPtr = NULL;
endPtr = _tcsrchr(thisPath, '\\');

if (baseName-endPtr < _tcslen(TEXT("\\jars\\"))) {
if ((size_t)(baseName-endPtr) < _tcslen(TEXT("\\jars\\"))) {
return NULL; // Not enough space to copy the path fragment in without clobbering the jar name.
}

Expand All @@ -347,7 +346,6 @@ PTSTR getCustomizedJavaCmd() {
PCTSTR javaHomeFragment = TEXT("\\customized.java.path");
const DWORD javaHomeFragmentLen = 22;
const size_t N = 1024;
DWORD baseNameLen;

javaHomePath = (PTSTR)malloc(N*sizeof(TCHAR));
if (N == GetModuleFileName(NULL, javaHomePath, N) && ERROR_INSUFFICIENT_BUFFER == GetLastError()) {
Expand Down Expand Up @@ -402,4 +400,4 @@ PTSTR getCustomizedJavaCmd() {
#else
return buffer;
#endif
}
}

0 comments on commit 75f0337

Please # to comment.