From: Eric Haszlakiewicz Date: Wed, 12 Feb 2014 04:16:53 +0000 (-0500) Subject: Fix Issue #111: Fix off-by-one error when range checking the input to json_tokener_er... X-Git-Tag: json-c-0.12-20140410~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=56df93d12857fb3d13f7e14391954e3b59708261;p=json-c Fix Issue #111: Fix off-by-one error when range checking the input to json_tokener_error_desc(). --- diff --git a/json_tokener.c b/json_tokener.c index a2a598b..4ebe712 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -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) / sizeof(json_tokener_errors[0]))) + 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]; }