EVALUATION
http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/520830f632e7
|
|
|
EVALUATION
http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/520830f632e7
|
|
|
EVALUATION
http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/520830f632e7
|
|
|
SUGGESTED FIX
in
template <>
void DCmdArgument<bool>::parse_value(const char* str, size_t len, TRAPS)
use the "len" argument to limit strcasecmp to only compare the part of the string that actually contains the "true" or "false" argument:
diff -r 4f25538b54c9 src/share/vm/services/diagnosticArgument.cpp
--- a/src/share/vm/services/diagnosticArgument.cpp
+++ b/src/share/vm/services/diagnosticArgument.cpp
@@ -62,9 +62,9 @@
if (len == 0) {
set_value(true);
} else {
- if (strcasecmp(str, "true") == 0) {
+ if (strncasecmp(str, "true", len) == 0) {
set_value(true);
- } else if (strcasecmp(str, "false") == 0) {
+ } else if (strncasecmp(str, "false", len) == 0) {
set_value(false);
} else {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
|
|
SUGGESTED FIX
The suggested fix would allow invalid boolean values like -all=truefalse.
Here's an improved fix that strictly checks the boolean values:
--- old/src/share/vm/services/diagnosticArgument.cpp Thu Jan 19 10:36:10 2012
+++ new/src/share/vm/services/diagnosticArgument.cpp Thu Jan 19 10:36:10 2012
@@ -62,9 +62,9 @@
if (len == 0) {
set_value(true);
} else {
- if (strcasecmp(str, "true") == 0) {
+ if (len == strlen("true") && strncasecmp(str, "true", len) == 0) {
set_value(true);
- } else if (strcasecmp(str, "false") == 0) {
+ } else if (len == strlen("false") && strncasecmp(str, "false", len) == 0) {
set_value(false);
} else {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
|
|
|