Merge pull request #104 from rouault/fix_json_tokener_error_desc_out_of_bounds_read

Fix potential out-of-bounds read in json_tokener_error_desc
This commit is contained in:
Eric Haszlakiewicz
2013-09-08 13:20:08 -07:00

View File

@@ -74,7 +74,7 @@ const char* json_tokener_errors[] = {
const char *json_tokener_error_desc(enum json_tokener_error jerr)
{
int jerr_int = (int)jerr;
if (jerr_int < 0 || jerr_int > (int)sizeof(json_tokener_errors))
if (jerr_int < 0 || jerr_int > (int)(sizeof(json_tokener_errors) / sizeof(json_tokener_errors[0])))
return "Unknown error, invalid json_tokener_error value passed to json_tokener_error_desc()";
return json_tokener_errors[jerr];
}