From 0a84e90eea0f3b6b7593ea5d554ada224b8c1725 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Wed, 23 May 2012 12:11:25 -0700 Subject: [PATCH] 7158801: Improve VM CompileOnly option Fixed buffer overflow during parsing flags -XX:CompileCommand=, -XX:CompileOnly= and command lines in .hotspot_compiler file. Reviewed-by: never --- hotspot/src/share/vm/compiler/compilerOracle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/compiler/compilerOracle.cpp b/hotspot/src/share/vm/compiler/compilerOracle.cpp index 07bc969b872..ce78ccbb501 100644 --- a/hotspot/src/share/vm/compiler/compilerOracle.cpp +++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp @@ -572,7 +572,7 @@ void CompilerOracle::parse_from_file() { char token[1024]; int pos = 0; int c = getc(stream); - while(c != EOF) { + while(c != EOF && pos < (sizeof(token)-1)) { if (c == '\n') { token[pos++] = '\0'; parse_from_line(token); @@ -593,7 +593,7 @@ void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char* int pos = 0; const char* sp = str; int c = *sp++; - while (c != '\0') { + while (c != '\0' && pos < (sizeof(token)-1)) { if (c == '\n') { token[pos++] = '\0'; parse_line(token);