From 56df93d12857fb3d13f7e14391954e3b59708261 Mon Sep 17 00:00:00 2001 From: Eric Haszlakiewicz Date: Tue, 11 Feb 2014 23:16:53 -0500 Subject: [PATCH] Fix Issue #111: Fix off-by-one error when range checking the input to json_tokener_error_desc(). --- json_tokener.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]; }