--- old/src/share/back/transport.c 2013-03-04 19:20:08.373722113 +0100 +++ new/src/share/back/transport.c 2013-03-04 19:20:08.221722106 +0100 @@ -117,6 +117,9 @@ /* Construct library name (simple name or full path) */ dbgsysBuildLibName(libname, sizeof(libname), plibdir, name); + if (strlen(libname) == 0) { + return NULL; + } /* dlopen (unix) / LoadLibrary (windows) the transport library */ handle = dbgsysLoadLibrary(libname, buf, sizeof(buf)); --- old/src/share/demo/jvmti/hprof/hprof_init.c 2013-03-04 19:20:09.061722146 +0100 +++ new/src/share/demo/jvmti/hprof/hprof_init.c 2013-03-04 19:20:08.889722137 +0100 @@ -1899,11 +1899,17 @@ */ getSystemProperty("sun.boot.library.path", &boot_path); md_build_library_name(lname, FILENAME_MAX, boot_path, name); + if ( strlen(lname) == 0 ) { + HPROF_ERROR(JNI_TRUE, "Could not find library"); + } jvmtiDeallocate(boot_path); handle = md_load_library(lname, err_buf, (int)sizeof(err_buf)); if ( handle == NULL ) { /* This may be necessary on Windows. */ md_build_library_name(lname, FILENAME_MAX, "", name); + if ( strlen(lname) == 0 ) { + HPROF_ERROR(JNI_TRUE, "Could not find library"); + } handle = md_load_library(lname, err_buf, (int)sizeof(err_buf)); if ( handle == NULL ) { HPROF_ERROR(JNI_TRUE, err_buf); @@ -1968,6 +1974,9 @@ getSystemProperty("sun.boot.library.path", &boot_path); /* Load in NPT library for character conversions */ md_build_library_name(npt_lib, sizeof(npt_lib), boot_path, NPT_LIBNAME); + if ( strlen(npt_lib) == 0 ) { + HPROF_ERROR(JNI_TRUE, "Could not find npt library"); + } jvmtiDeallocate(boot_path); NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL); if ( gdata->npt == NULL ) { --- old/src/solaris/back/linker_md.c 2013-03-04 19:20:09.757722177 +0100 +++ new/src/solaris/back/linker_md.c 2013-03-04 19:20:09.589722170 +0100 @@ -60,6 +60,7 @@ char *path_sep = PATH_SEPARATOR; char *pathname = (char *)pname; + *buffer = '\0'; while (strlen(pathname) > 0) { char *p = strchr(pathname, *path_sep); if (p == NULL) { @@ -69,13 +70,17 @@ if (p == pathname) { continue; } - (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (p - pathname), + (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (int)(p - pathname), pathname, fname); if (access(buffer, F_OK) == 0) { break; } - pathname = p + 1; + if (*p == '\0') { + pathname = p; + } else { + pathname = p + 1; + } *buffer = '\0'; } } --- old/src/solaris/demo/jvmti/hprof/hprof_md.c 2013-03-04 19:20:10.433722209 +0100 +++ new/src/solaris/demo/jvmti/hprof/hprof_md.c 2013-03-04 19:20:10.261722202 +0100 @@ -385,6 +385,7 @@ // Loosely based on os_solaris.cpp char *pathname = (char *)pname; + *buffer = '\0'; while (strlen(pathname) > 0) { char *p = strchr(pathname, ':'); if (p == NULL) { @@ -395,12 +396,16 @@ continue; } (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX, - (p - pathname), pathname, fname); + (int)(p - pathname), pathname, fname); if (access(buffer, F_OK) == 0) { - break; + break; } - pathname = p + 1; + if (*p == '\0') { + pathname = p; + } else { + pathname = p + 1; + } *buffer = '\0'; } } --- old/src/windows/back/linker_md.c 2013-03-04 19:20:11.113722241 +0100 +++ new/src/windows/back/linker_md.c 2013-03-04 19:20:10.941722232 +0100 @@ -44,6 +44,7 @@ char *path_sep = PATH_SEPARATOR; char *pathname = (char *)pname; + *buffer = '\0'; while (strlen(pathname) > 0) { char *p = strchr(pathname, *path_sep); if (p == NULL) { @@ -54,16 +55,20 @@ continue; } if (*(p-1) == ':' || *(p-1) == '\\') { - (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname), + (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname), pathname, fname); } else { - (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname), + (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname), pathname, fname); } if (_access(buffer, 0) == 0) { break; } - pathname = p + 1; + if (*p == '\0') { + pathname = p; + } else { + pathname = p + 1; + } *buffer = '\0'; } } --- old/src/windows/demo/jvmti/hprof/hprof_md.c 2013-03-04 19:20:11.785722272 +0100 +++ new/src/windows/demo/jvmti/hprof/hprof_md.c 2013-03-04 19:20:11.613722264 +0100 @@ -372,6 +372,7 @@ // Loosley based on os_windows.cpp char *pathname = (char *)pname; + *buffer = '\0'; while (strlen(pathname) > 0) { char *p = strchr(pathname, ';'); if (p == NULL) { @@ -382,16 +383,20 @@ continue; } if (*(p-1) == ':' || *(p-1) == '\\') { - (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname), + (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname), pathname, fname); } else { - (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname), + (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname), pathname, fname); } if (_access(buffer, 0) == 0) { break; } - pathname = p + 1; + if (*p == '\0') { + pathname = p; + } else { + pathname = p + 1; + } *buffer = '\0'; } }