mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
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:
parent
40d5fa156c
commit
dd5c8eb660
9 changed files with 67 additions and 35 deletions
|
@ -1198,19 +1198,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) + strlen(JNI_LIB_PREFIX) + strlen(JNI_LIB_SUFFIX) + 2 > buflen) {
|
||||
*buffer = '\0';
|
||||
return;
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (pnamelen == 0) {
|
||||
snprintf(buffer, buflen, JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, fname);
|
||||
retval = true;
|
||||
} else if (strchr(pname, *os::path_separator()) != NULL) {
|
||||
int n;
|
||||
char** pelements = split_path(pname, &n);
|
||||
|
@ -1222,6 +1223,7 @@ void os::dll_build_name(char* buffer, size_t buflen,
|
|||
snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX,
|
||||
pelements[i], fname);
|
||||
if (file_exists(buffer)) {
|
||||
retval = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1236,7 +1238,9 @@ void os::dll_build_name(char* buffer, size_t buflen,
|
|||
}
|
||||
} else {
|
||||
snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pname, fname);
|
||||
retval = true;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
const char* os::get_current_directory(char *buf, int buflen) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue