Mercurial > hg > truffle
comparison src/os/windows/vm/os_windows.cpp @ 17567:5656140324ed
8030763: Validate global memory allocation
Summary: Add length checks where necessary
Reviewed-by: coleenp, mschoene
author | hseigel |
---|---|
date | Thu, 13 Feb 2014 11:28:17 -0500 |
parents | 179cd89fb279 |
children | 3eed8712d410 364b73402247 |
comparison
equal
deleted
inserted
replaced
17566:bf4dc2e29b5c | 17567:5656140324ed |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
1817 // JAVA_HOME environment variable | 1817 // JAVA_HOME environment variable |
1818 // and fix up the path so it looks like | 1818 // and fix up the path so it looks like |
1819 // libjvm.so is installed there (append a fake suffix | 1819 // libjvm.so is installed there (append a fake suffix |
1820 // hotspot/libjvm.so). | 1820 // hotspot/libjvm.so). |
1821 char* java_home_var = ::getenv("JAVA_HOME"); | 1821 char* java_home_var = ::getenv("JAVA_HOME"); |
1822 if (java_home_var != NULL && java_home_var[0] != 0) { | 1822 if (java_home_var != NULL && java_home_var[0] != 0 && |
1823 strlen(java_home_var) < (size_t)buflen) { | |
1823 | 1824 |
1824 strncpy(buf, java_home_var, buflen); | 1825 strncpy(buf, java_home_var, buflen); |
1825 | 1826 |
1826 // determine if this is a legacy image or modules image | 1827 // determine if this is a legacy image or modules image |
1827 // modules image doesn't have "jre" subdirectory | 1828 // modules image doesn't have "jre" subdirectory |
1835 jio_snprintf(buf + len, buflen-len, "hotspot\\jvm.dll"); | 1836 jio_snprintf(buf + len, buflen-len, "hotspot\\jvm.dll"); |
1836 } | 1837 } |
1837 } | 1838 } |
1838 | 1839 |
1839 if(buf[0] == '\0') { | 1840 if(buf[0] == '\0') { |
1840 GetModuleFileName(vm_lib_handle, buf, buflen); | 1841 GetModuleFileName(vm_lib_handle, buf, buflen); |
1841 } | 1842 } |
1842 strcpy(saved_jvm_path, buf); | 1843 strncpy(saved_jvm_path, buf, MAX_PATH); |
1843 } | 1844 } |
1844 | 1845 |
1845 | 1846 |
1846 void os::print_jni_name_prefix_on(outputStream* st, int args_size) { | 1847 void os::print_jni_name_prefix_on(outputStream* st, int args_size) { |
1847 #ifndef _WIN64 | 1848 #ifndef _WIN64 |
2288 ctx->MxCsr = MxCsr; | 2289 ctx->MxCsr = MxCsr; |
2289 return EXCEPTION_CONTINUE_EXECUTION; | 2290 return EXCEPTION_CONTINUE_EXECUTION; |
2290 } | 2291 } |
2291 | 2292 |
2292 */ | 2293 */ |
2293 #endif //_WIN64 | 2294 #endif // _WIN64 |
2294 | 2295 |
2295 | |
2296 // Fatal error reporting is single threaded so we can make this a | |
2297 // static and preallocated. If it's more than MAX_PATH silently ignore | |
2298 // it. | |
2299 static char saved_error_file[MAX_PATH] = {0}; | |
2300 | |
2301 void os::set_error_file(const char *logfile) { | |
2302 if (strlen(logfile) <= MAX_PATH) { | |
2303 strncpy(saved_error_file, logfile, MAX_PATH); | |
2304 } | |
2305 } | |
2306 | 2296 |
2307 static inline void report_error(Thread* t, DWORD exception_code, | 2297 static inline void report_error(Thread* t, DWORD exception_code, |
2308 address addr, void* siginfo, void* context) { | 2298 address addr, void* siginfo, void* context) { |
2309 VMError err(t, exception_code, addr, siginfo, context); | 2299 VMError err(t, exception_code, addr, siginfo, context); |
2310 err.report_and_die(); | 2300 err.report_and_die(); |