comparison src/share/vm/services/diagnosticArgument.cpp @ 4849:520830f632e7

7131346: Parsing of boolean arguments to diagnostic commands is broken Reviewed-by: dholmes, dcubed
author fparain
date Wed, 25 Jan 2012 10:32:29 -0800
parents 3b688d6ff3d0
children f1cb6f9cfe21
comparison
equal deleted inserted replaced
4847:78dadb7b16ab 4849:520830f632e7
1 /* 1 /*
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2011, 2012 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.
57 57
58 template <> void DCmdArgument<jlong>::destroy_value() { } 58 template <> void DCmdArgument<jlong>::destroy_value() { }
59 59
60 template <> void DCmdArgument<bool>::parse_value(const char* str, 60 template <> void DCmdArgument<bool>::parse_value(const char* str,
61 size_t len, TRAPS) { 61 size_t len, TRAPS) {
62 // len is the length of the current token starting at str
62 if (len == 0) { 63 if (len == 0) {
63 set_value(true); 64 set_value(true);
64 } else { 65 } else {
65 if (strcasecmp(str, "true") == 0) { 66 if (len == strlen("true") && strncasecmp(str, "true", len) == 0) {
66 set_value(true); 67 set_value(true);
67 } else if (strcasecmp(str, "false") == 0) { 68 } else if (len == strlen("false") && strncasecmp(str, "false", len) == 0) {
68 set_value(false); 69 set_value(false);
69 } else { 70 } else {
70 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), 71 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
71 "Boolean parsing error in diagnostic command arguments"); 72 "Boolean parsing error in diagnostic command arguments");
72 } 73 }