Mercurial > hg > graal-compiler
comparison src/share/vm/services/memTracker.cpp @ 7172:bbc14465e7db
8003689: MemTracker::init_tracking_options() reads outside array if commandline argument is empty
Summary: Fixed potential buffer overrun when giving empty option to NativeMemoryTracking commandline option
Reviewed-by: ctornqvi, hseigel, kvn
author | zgu |
---|---|
date | Wed, 28 Nov 2012 09:19:38 -0500 |
parents | 716c64bda5ba |
children | ecd24264898b |
comparison
equal
deleted
inserted
replaced
7170:ca1be5fbe6ff | 7172:bbc14465e7db |
---|---|
67 debug_only(intx MemTracker::_main_thread_tid = 0;) | 67 debug_only(intx MemTracker::_main_thread_tid = 0;) |
68 NOT_PRODUCT(volatile jint MemTracker::_pending_recorder_count = 0;) | 68 NOT_PRODUCT(volatile jint MemTracker::_pending_recorder_count = 0;) |
69 | 69 |
70 void MemTracker::init_tracking_options(const char* option_line) { | 70 void MemTracker::init_tracking_options(const char* option_line) { |
71 _tracking_level = NMT_off; | 71 _tracking_level = NMT_off; |
72 if (strncmp(option_line, "=summary", 8) == 0) { | 72 if (strcmp(option_line, "=summary") == 0) { |
73 _tracking_level = NMT_summary; | 73 _tracking_level = NMT_summary; |
74 } else if (strncmp(option_line, "=detail", 7) == 0) { | 74 } else if (strcmp(option_line, "=detail") == 0) { |
75 _tracking_level = NMT_detail; | 75 _tracking_level = NMT_detail; |
76 } else { | 76 } else if (strcmp(option_line, "=off") != 0) { |
77 char msg[255]; | 77 vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL); |
78 //+1 to remove the '=' character | |
79 jio_snprintf(msg, 255, "Unknown option given to XX:NativeMemoryTracking: %s", option_line+1); | |
80 vm_exit_during_initialization(msg, NULL); | |
81 } | 78 } |
82 } | 79 } |
83 | 80 |
84 // first phase of bootstrapping, when VM is still in single-threaded mode. | 81 // first phase of bootstrapping, when VM is still in single-threaded mode. |
85 void MemTracker::bootstrap_single_thread() { | 82 void MemTracker::bootstrap_single_thread() { |