8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken

Dll_dir can contain multiple paths, need to parse them correctly when loading agents

Reviewed-by: dholmes, dlong
This commit is contained in:
Bill Pittore 2012-11-07 17:53:02 -05:00 committed by Bill Pittore
parent 40d5fa156c
commit dd5c8eb660
9 changed files with 67 additions and 35 deletions

View file

@ -1132,21 +1132,23 @@ static bool file_exists(const char* filename) {
return GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES;
}
void os::dll_build_name(char *buffer, size_t buflen,
bool os::dll_build_name(char *buffer, size_t buflen,
const char* pname, const char* fname) {
bool retval = false;
const size_t pnamelen = pname ? strlen(pname) : 0;
const char c = (pnamelen > 0) ? pname[pnamelen-1] : 0;
// Quietly truncates on buffer overflow. Should be an error.
// Return error on buffer overflow.
if (pnamelen + strlen(fname) + 10 > buflen) {
*buffer = '\0';
return;
return retval;
}
if (pnamelen == 0) {
jio_snprintf(buffer, buflen, "%s.dll", fname);
retval = true;
} else if (c == ':' || c == '\\') {
jio_snprintf(buffer, buflen, "%s%s.dll", pname, fname);
retval = true;
} else if (strchr(pname, *os::path_separator()) != NULL) {
int n;
char** pelements = split_path(pname, &n);
@ -1164,6 +1166,7 @@ void os::dll_build_name(char *buffer, size_t buflen,
jio_snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
}
if (file_exists(buffer)) {
retval = true;
break;
}
}
@ -1178,7 +1181,9 @@ void os::dll_build_name(char *buffer, size_t buflen,
}
} else {
jio_snprintf(buffer, buflen, "%s\\%s.dll", pname, fname);
retval = true;
}
return retval;
}
// Needs to be in os specific directory because windows requires another