jdk/src/windows/bin/java_md.c

Print this page
rev 5689 : 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
Reviewed-by: darcy, jjh, mschoene

*** 99,109 **** #define PARAM_D3D "-Dsun.java2d.d3d" #define PARAM_OPENGL "-Dsun.java2d.opengl" /* funtion in awt.dll (src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp) */ #define D3D_PRELOAD_FUNC "preloadD3D" - /* Extracts value of a parameter with the specified name * from command line argument (returns pointer in the argument). * Returns NULL if the argument does not contains the parameter. * e.g.: * GetParamValue("theParam", "theParam=value") returns pointer to "value". --- 99,108 ----
*** 274,284 **** #if _MSC_VER >= 1600 #define CRT_DLL "msvcr100.dll" #endif #ifdef CRT_DLL if (GetJREPath(crtpath, MAXPATHLEN)) { ! if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + JLI_StrLen(CRT_DLL) >= MAXPATHLEN) { JLI_ReportErrorMessage(JRE_ERROR11); return JNI_FALSE; } (void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL); /* Add crt dll */ JLI_TraceLauncher("CRT path is %s\n", crtpath); --- 273,284 ---- #if _MSC_VER >= 1600 #define CRT_DLL "msvcr100.dll" #endif #ifdef CRT_DLL if (GetJREPath(crtpath, MAXPATHLEN)) { ! if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + ! JLI_StrLen(CRT_DLL) >= MAXPATHLEN) { JLI_ReportErrorMessage(JRE_ERROR11); return JNI_FALSE; } (void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL); /* Add crt dll */ JLI_TraceLauncher("CRT path is %s\n", crtpath);
*** 345,355 **** { struct stat s; if (JLI_StrChr(jvmtype, '/') || JLI_StrChr(jvmtype, '\\')) { JLI_Snprintf(jvmpath, jvmpathsize, "%s\\" JVM_DLL, jvmtype); } else { ! JLI_Snprintf(jvmpath, jvmpathsize, "%s\\bin\\%s\\" JVM_DLL, jrepath, jvmtype); } if (stat(jvmpath, &s) == 0) { return JNI_TRUE; } else { return JNI_FALSE; --- 345,356 ---- { struct stat s; if (JLI_StrChr(jvmtype, '/') || JLI_StrChr(jvmtype, '\\')) { JLI_Snprintf(jvmpath, jvmpathsize, "%s\\" JVM_DLL, jvmtype); } else { ! JLI_Snprintf(jvmpath, jvmpathsize, "%s\\bin\\%s\\" JVM_DLL, ! jrepath, jvmtype); } if (stat(jvmpath, &s) == 0) { return JNI_TRUE; } else { return JNI_FALSE;
*** 523,532 **** --- 524,564 ---- if (!counterAvailable || !counterInitialized) { return 0; } return (counts * 1000 * 1000)/counterFrequency.QuadPart; } + /* + * windows snprintf does not guarantee a null terminator in the buffer, + * if the computed size is equal to or greater than the buffer size, + * as well as error conditions. This function guarantees a null terminator + * under all these conditions. An unreasonable buffer or size will return + * an error value. Under all other conditions this function will return the + * size of the bytes actually written minus the null terminator, similar + * to ansi snprintf api. Thus when calling this function the caller must + * ensure storage for the null terminator. + */ + int + JLI_Snprintf(char* buffer, size_t size, const char* format, ...) { + int rc; + va_list vl; + if (size == 0 || buffer == NULL) + return -1; + buffer[0] = '\0'; + va_start(vl, format); + rc = vsnprintf(buffer, size, format, vl); + va_end(vl); + /* force a null terminator, if something is amiss */ + if (rc < 0) { + /* apply ansi semantics */ + buffer[size - 1] = '\0'; + return size; + } else if (rc == size) { + /* force a null terminator */ + buffer[size - 1] = '\0'; + } + return rc; + } void JLI_ReportErrorMessage(const char* fmt, ...) { va_list vl; va_start(vl,fmt);
*** 878,888 **** * the exact same Java environment, regardless of the version of the arbitrary * launcher we start with. */ void ExecJRE(char *jre, char **argv) { ! int len; char path[MAXPATHLEN + 1]; const char *progname = GetProgramName(); /* --- 910,920 ---- * the exact same Java environment, regardless of the version of the arbitrary * launcher we start with. */ void ExecJRE(char *jre, char **argv) { ! jint len; char path[MAXPATHLEN + 1]; const char *progname = GetProgramName(); /*
*** 1415,1425 **** // indicator char + String + NULL terminator, the java method will strip // out the first character, the indicator character, so no matter what // we add the indicator tlen = 1 + JLI_StrLen(strv[i]) + 1; nargv[i] = (char *) JLI_MemAlloc(tlen); ! JLI_Snprintf(nargv[i], tlen, "%c%s", arg_expand ? 'T' : 'F', strv[i]); JLI_TraceLauncher("%s\n", nargv[i]); } if (!needs_expansion) { // clean up any allocated memory and return back the old arguments --- 1447,1460 ---- // indicator char + String + NULL terminator, the java method will strip // out the first character, the indicator character, so no matter what // we add the indicator tlen = 1 + JLI_StrLen(strv[i]) + 1; nargv[i] = (char *) JLI_MemAlloc(tlen); ! if (JLI_Snprintf(nargv[i], tlen, "%c%s", arg_expand ? 'T' : 'F', ! strv[i]) < 0) { ! return NULL; ! } JLI_TraceLauncher("%s\n", nargv[i]); } if (!needs_expansion) { // clean up any allocated memory and return back the old arguments