7158804: Improve config file parsing

Check buffer length when reading

Reviewed-by: dholmes, dcubed
This commit is contained in:
Keith McGuigan 2012-06-08 12:49:12 -04:00
parent 0a84e90eea
commit c39971d4f1
3 changed files with 33 additions and 3 deletions

View file

@ -572,7 +572,7 @@ void CompilerOracle::parse_from_file() {
char token[1024];
int pos = 0;
int c = getc(stream);
while(c != EOF && pos < (sizeof(token)-1)) {
while(c != EOF && pos < (int)(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' && pos < (sizeof(token)-1)) {
while (c != '\0' && pos < (int)(sizeof(token)-1)) {
if (c == '\n') {
token[pos++] = '\0';
parse_line(token);