fixed bool parsing bug -- off by one on the string size enforcement
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 5 Feb 2007 16:20:39 +0000 (16:20 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 5 Feb 2007 16:20:39 +0000 (16:20 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@817 9efc2488-bf62-4759-914b-345cdb29e865

src/objson/json_parser.c

index 5ed5cd6..d75431f 100644 (file)
@@ -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;
        }