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

@ -1650,19 +1650,20 @@ static bool file_exists(const char* filename) {
return os::stat(filename, &statbuf) == 0;
}
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;
// Copied from libhpi
const size_t pnamelen = pname ? strlen(pname) : 0;
// Quietly truncate on buffer overflow. Should be an error.
// Return error on buffer overflow.
if (pnamelen + strlen(fname) + 10 > (size_t) buflen) {
*buffer = '\0';
return;
return retval;
}
if (pnamelen == 0) {
snprintf(buffer, buflen, "lib%s.so", fname);
retval = true;
} else if (strchr(pname, *os::path_separator()) != NULL) {
int n;
char** pelements = split_path(pname, &n);
@ -1673,6 +1674,7 @@ void os::dll_build_name(char* buffer, size_t buflen,
}
snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname);
if (file_exists(buffer)) {
retval = true;
break;
}
}
@ -1687,7 +1689,9 @@ void os::dll_build_name(char* buffer, size_t buflen,
}
} else {
snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
retval = true;
}
return retval;
}
const char* os::get_current_directory(char *buf, int buflen) {