< prev index next >

src/os/bsd/vm/os_bsd.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

*** 1,7 **** /* ! * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 1752,1762 **** CAST_FROM_FN_PTR(address, os::jvm_path), dli_fname, sizeof(dli_fname), NULL); assert(ret, "cannot locate libjvm"); char *rp = NULL; if (ret && dli_fname[0] != '\0') { ! rp = realpath(dli_fname, buf); } if (rp == NULL) { return; } --- 1752,1762 ---- CAST_FROM_FN_PTR(address, os::jvm_path), dli_fname, sizeof(dli_fname), NULL); assert(ret, "cannot locate libjvm"); char *rp = NULL; if (ret && dli_fname[0] != '\0') { ! rp = os::Posix::realpath(dli_fname, buf, buflen); } if (rp == NULL) { return; }
*** 1784,1794 **** // Check the current module name "libjvm" p = strrchr(buf, '/'); assert(strstr(p, "/libjvm") == p, "invalid library name"); ! rp = realpath(java_home_var, buf); if (rp == NULL) { return; } // determine if this is a legacy image or modules image --- 1784,1794 ---- // Check the current module name "libjvm" p = strrchr(buf, '/'); assert(strstr(p, "/libjvm") == p, "invalid library name"); ! rp = os::Posix::realpath(java_home_var, buf, buflen); if (rp == NULL) { return; } // determine if this is a legacy image or modules image
*** 1818,1828 **** // Use current module name "libjvm" len = strlen(buf); snprintf(buf + len, buflen-len, "/libjvm%s", JNI_LIB_SUFFIX); } else { // Fall back to path of current library ! rp = realpath(dli_fname, buf); if (rp == NULL) { return; } } } --- 1818,1828 ---- // Use current module name "libjvm" len = strlen(buf); snprintf(buf + len, buflen-len, "/libjvm%s", JNI_LIB_SUFFIX); } else { // Fall back to path of current library ! rp = os::Posix::realpath(dli_fname, buf, buflen); if (rp == NULL) { return; } } }
< prev index next >