< prev index next >
src/os/solaris/vm/os_solaris.cpp
Print this page
rev 12684 : 8173848: realpath is unsafe
Summary: Fix occurrences of realpath in hotspot to use safe POSIX.1-2008 form, if possible.
Reviewed-by: dsamersoff
*** 2032,2042 ****
Dl_info dlinfo;
int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo);
assert(ret != 0, "cannot locate libjvm");
if (ret != 0 && dlinfo.dli_fname != NULL) {
! realpath((char *)dlinfo.dli_fname, buf);
} else {
buf[0] = '\0';
return;
}
--- 2032,2042 ----
Dl_info dlinfo;
int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo);
assert(ret != 0, "cannot locate libjvm");
if (ret != 0 && dlinfo.dli_fname != NULL) {
! os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen);
} else {
buf[0] = '\0';
return;
}
*** 2063,2073 ****
// Check the current module name "libjvm.so".
p = strrchr(buf, '/');
assert(strstr(p, "/libjvm") == p, "invalid library name");
! realpath(java_home_var, buf);
// determine if this is a legacy image or modules image
// modules image doesn't have "jre" subdirectory
len = strlen(buf);
assert(len < buflen, "Ran out of buffer space");
jrelib_p = buf + len;
--- 2063,2073 ----
// Check the current module name "libjvm.so".
p = strrchr(buf, '/');
assert(strstr(p, "/libjvm") == p, "invalid library name");
! os::Posix::realpath(java_home_var, buf, buflen);
// determine if this is a legacy image or modules image
// modules image doesn't have "jre" subdirectory
len = strlen(buf);
assert(len < buflen, "Ran out of buffer space");
jrelib_p = buf + len;
*** 2080,2090 ****
// Use current module name "libjvm.so"
len = strlen(buf);
snprintf(buf + len, buflen-len, "/hotspot/libjvm.so");
} else {
// Go back to path of .so
! realpath((char *)dlinfo.dli_fname, buf);
}
}
}
}
--- 2080,2090 ----
// Use current module name "libjvm.so"
len = strlen(buf);
snprintf(buf + len, buflen-len, "/hotspot/libjvm.so");
} else {
// Go back to path of .so
! os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen);
}
}
}
}
< prev index next >