remove spaces around value list assignment, fix for invalid hex in value list

This commit is contained in:
john30
2016-01-30 17:29:34 +01:00
parent a0fdf2d5be
commit 88d3086a6d
2 changed files with 18 additions and 8 deletions
+15 -6
View File
@@ -265,16 +265,25 @@ result_t DataField::create(vector<string>::iterator& it,
const char* str = token.c_str();
char* strEnd = NULL;
unsigned long int id;
if (strncasecmp(str, "0x", 2) == 0)
id = strtoul(str+2, &strEnd, 16); // hexadecimal
else
if (strncasecmp(str, "0x", 2) == 0) {
str += 2;
id = strtoul(str, &strEnd, 16); // hexadecimal
} else {
id = strtoul(str, &strEnd, 10); // decimal
if (strEnd == NULL || strEnd == str || *strEnd != '=' || id > MAX_VALUE) {
}
if (strEnd == NULL || strEnd == str || id > MAX_VALUE) {
result = RESULT_ERR_INVALID_LIST;
break;
}
values[(unsigned int)id] = string(strEnd + 1);
// remove blanks around '=' sign
while (*strEnd == ' ') strEnd++;
if (*strEnd != '=') {
result = RESULT_ERR_INVALID_LIST;
break;
}
token = string(strEnd + 1);
FileReader::trim(token);
values[(unsigned int)id] = token;
}
}
if (result != RESULT_OK)