From b0f238fe376845bfd8efb879905d5259c16e6f57 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 5 Feb 2007 16:20:39 +0000 Subject: [PATCH] fixed bool parsing bug -- off by one on the string size enforcement git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@817 9efc2488-bf62-4759-914b-345cdb29e865 --- src/objson/json_parser.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/objson/json_parser.c b/src/objson/json_parser.c index 5ed5cd6..d75431f 100644 --- a/src/objson/json_parser.c +++ b/src/objson/json_parser.c @@ -184,22 +184,22 @@ int json_parse_json_bool(char* string, unsigned long* index, jsonObject* obj, in char* ret = "json_parse_json_bool(): truncated bool"; - if( *index >= (current_strlen - 5)) + if( *index > (current_strlen - 4)) return json_handle_error(string, index, ret); - - if(!strncasecmp( string + (*index), "false", 5)) { - (*index) += 5; - obj->value.b = 0; + + if(!strncasecmp( string + (*index), "true", 4)) { + (*index) += 4; + obj->value.b = 1; obj->type = JSON_BOOL; return 0; } - if( *index >= (current_strlen - 4)) + if( *index > (current_strlen - 5)) return json_handle_error(string, index, ret); - - if(!strncasecmp( string + (*index), "true", 4)) { - (*index) += 4; - obj->value.b = 1; + + if(!strncasecmp( string + (*index), "false", 5)) { + (*index) += 5; + obj->value.b = 0; obj->type = JSON_BOOL; return 0; } -- 2.43.2