mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8030763: Validate global memory allocation
Add length checks where necessary Reviewed-by: coleenp, mschoene
This commit is contained in:
parent
5323c1c179
commit
7ec22758dc
7 changed files with 11 additions and 30 deletions
|
@ -1824,7 +1824,9 @@ void os::jvm_path(char *buf, jint buflen) {
|
|||
// looks like jvm.dll is installed there (append a fake suffix
|
||||
// hotspot/jvm.dll).
|
||||
char* java_home_var = ::getenv("JAVA_HOME");
|
||||
if (java_home_var != NULL && java_home_var[0] != 0) {
|
||||
if (java_home_var != NULL && java_home_var[0] != 0 &&
|
||||
strlen(java_home_var) < (size_t)buflen) {
|
||||
|
||||
strncpy(buf, java_home_var, buflen);
|
||||
|
||||
// determine if this is a legacy image or modules image
|
||||
|
@ -1843,7 +1845,7 @@ void os::jvm_path(char *buf, jint buflen) {
|
|||
if (buf[0] == '\0') {
|
||||
GetModuleFileName(vm_lib_handle, buf, buflen);
|
||||
}
|
||||
strcpy(saved_jvm_path, buf);
|
||||
strncpy(saved_jvm_path, buf, MAX_PATH);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2291,17 +2293,6 @@ LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
|||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
// Fatal error reporting is single threaded so we can make this a
|
||||
// static and preallocated. If it's more than MAX_PATH silently ignore
|
||||
// it.
|
||||
static char saved_error_file[MAX_PATH] = {0};
|
||||
|
||||
void os::set_error_file(const char *logfile) {
|
||||
if (strlen(logfile) <= MAX_PATH) {
|
||||
strncpy(saved_error_file, logfile, MAX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void report_error(Thread* t, DWORD exception_code,
|
||||
address addr, void* siginfo, void* context) {
|
||||
VMError err(t, exception_code, addr, siginfo, context);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue