Revision2: Corrected: RFR 8059557 (XL): Validate JVM Command-Line Flag Arguments
Kim Barrett
kim.barrett at oracle.com
Wed Jun 3 20:09:38 UTC 2015
On Jun 3, 2015, at 3:56 PM, Gerard Ziemski <gerard.ziemski at oracle.com> wrote:
>
>
>
> On 6/3/2015 2:37 PM, Kim Barrett wrote:
>> On Jun 2, 2015, at 6:52 PM, Kim Barrett <kim.barrett at oracle.com> wrote:
>>> On May 27, 2015, at 5:28 PM, Gerard Ziemski <gerard.ziemski at oracle.com> wrote:
>>>> hi all,
>>>>
>>>> Here is a revision 2 of the feature taking into account feedback from Dmitry, David, Kim and Alexander.
>>>> ...
>>>>
>>>> References:
>>>>
>>>> Webrev: http://cr.openjdk.java.net/~gziemski/8059557_rev2
>>>> note: due to "awk" limit of 50 pats the Frames diff is not available for "src/share/vm/runtime/arguments.cpp”
>> One more:
>>
>> ------------------------------------------------------------------------------
>> src/share/vm/services/writeableFlags.cpp
>> 46 for (int i=0; i<TEMP_BUF_SIZE-1; i++) {
>>
>> That should be "j < TEMP_BUF_SIZE-1". j is the index into the
>> range_string_no_whitespaces buffer that needs to be limited.
>
And another:
------------------------------------------------------------------------------
src/share/vm/services/writeableFlags.cpp
43 char* range_string = stream.as_string();
44 char range_string_no_whitespaces[TEMP_BUF_SIZE];
45 int j = 0;
46 for (int i=0; i<TEMP_BUF_SIZE-1; i++) {
47 if (range_string[i] == '\0') {
48 break;
49 } else if (range_string[i] != ' ') {
50 range_string_no_whitespaces[j] = range_string[i];
51 j++;
52 }
53 }
54 range_string_no_whitespaces[j] = '\0';
55
56 os::strlcat(buffer, range_string_no_whitespaces, TEMP_BUF_SIZE);
i & j should be size_t.
range_string should be const char*.
We don't really need range_string_no_whitespaces. Instead, initialize
j to strlen(buffer) and copy directly into buffer, e.g. replace the
above with (including other previously suggested changes)
43 const char* range_string = stream.as_string();
44 size_t j = strlen(buffer);
45 for (size_t i=0; j<TEMP_BUF_SIZE-1; i++) {
46 if (range_string[i] == '\0') {
47 break;
48 } else if (range_string[i] != ' ') {
49 buffer[j] = range_string[i];
50 j++;
51 }
52 }
53 buffer[j] = '\0';
------------------------------------------------------------------------------
More information about the hotspot-dev
mailing list