< prev index next >

src/os/solaris/vm/os_solaris.cpp

Print this page
rev 12741 : 8173848: realpath is unsafe
Summary: Fix occurrences of realpath in hotspot to use safe POSIX.1-2008 form.
Reviewed-by: dsamersoff, dholmes, clanger

*** 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,2044 ---- 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) { ! if (os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen) == NULL) { ! return; ! } } 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; --- 2065,2077 ---- // Check the current module name "libjvm.so". p = strrchr(buf, '/'); assert(strstr(p, "/libjvm") == p, "invalid library name"); ! if (os::Posix::realpath(java_home_var, buf, buflen) == NULL) { ! return; ! } // 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); } } } } --- 2084,2096 ---- // Use current module name "libjvm.so" len = strlen(buf); snprintf(buf + len, buflen-len, "/hotspot/libjvm.so"); } else { // Go back to path of .so ! if (os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen) == NULL) { ! return; ! } } } } }
< prev index next >