comparison src/share/vm/runtime/arguments.cpp @ 12896:027006a47a6d

8025661: Ill-formed -Xminf and -Xmaxf options values interpreted as 0 Summary: Using strtod() instead of atof() when parsing -Xminf and -Xmaxf. Reviewed-by: brutisso, pliden
author sjohanss
date Mon, 14 Oct 2013 14:21:34 +0200
parents aa6f2ea19d8f
children b2ee5dc63353
comparison
equal deleted inserted replaced
12894:24f32d09a0d7 12896:027006a47a6d
2692 return JNI_EINVAL; 2692 return JNI_EINVAL;
2693 } 2693 }
2694 FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size); 2694 FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
2695 // Xmaxf 2695 // Xmaxf
2696 } else if (match_option(option, "-Xmaxf", &tail)) { 2696 } else if (match_option(option, "-Xmaxf", &tail)) {
2697 int maxf = (int)(atof(tail) * 100); 2697 char* err;
2698 if (maxf < 0 || maxf > 100) { 2698 int maxf = (int)(strtod(tail, &err) * 100);
2699 if (*err != '\0' || maxf < 0 || maxf > 100) {
2699 jio_fprintf(defaultStream::error_stream(), 2700 jio_fprintf(defaultStream::error_stream(),
2700 "Bad max heap free percentage size: %s\n", 2701 "Bad max heap free percentage size: %s\n",
2701 option->optionString); 2702 option->optionString);
2702 return JNI_EINVAL; 2703 return JNI_EINVAL;
2703 } else { 2704 } else {
2704 FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf); 2705 FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf);
2705 } 2706 }
2706 // Xminf 2707 // Xminf
2707 } else if (match_option(option, "-Xminf", &tail)) { 2708 } else if (match_option(option, "-Xminf", &tail)) {
2708 int minf = (int)(atof(tail) * 100); 2709 char* err;
2709 if (minf < 0 || minf > 100) { 2710 int minf = (int)(strtod(tail, &err) * 100);
2711 if (*err != '\0' || minf < 0 || minf > 100) {
2710 jio_fprintf(defaultStream::error_stream(), 2712 jio_fprintf(defaultStream::error_stream(),
2711 "Bad min heap free percentage size: %s\n", 2713 "Bad min heap free percentage size: %s\n",
2712 option->optionString); 2714 option->optionString);
2713 return JNI_EINVAL; 2715 return JNI_EINVAL;
2714 } else { 2716 } else {