summaryrefslogtreecommitdiff
path: root/json_tokener.c
AgeCommit message (Collapse)AuthorFilesLines
2015-03-03Merge pull request #168 from bugness-chl/masterHEADmasterEric Haszlakiewicz1-1/+36
Tightening the number parsing algorithm
2015-02-05Tightening the number parsing algorithmchl1-1/+36
Some badly formated "numbers" could get partly parsed, resulting in truncated results instead of raising an error. Examples : '1.2.3' -> (double)1.2 '2015-01-15' -> (int)2015 This patch is not perfect (ex: input can still end with a 'E', which is forbidden by json.org doc) but should avoid non-sensically formated input. Tests added.
2014-08-26Remove trailing whitespaceMichael Vetter1-1/+1
2014-05-04Move the json_min() and json_max() macros to json_util.h and mark everything ↵Eric Haszlakiewicz1-2/+3
else in bits.h deprecated. Eliminate all uses of bits.h within the json-c code.
2014-04-11Remove unused variable 'size'Petar Koretić1-2/+0
2014-04-09Patch to address the following issues:Michael Clark1-0/+11
* CVE-2013-6371: hash collision denial of service * CVE-2013-6370: buffer overflow if size_t is larger than int
2014-03-22Make the json_tokener_errors array local. It has been deprecated for a ↵Eric Haszlakiewicz1-2/+1
while, and json_tokener_error_desc() should be used instead.
2014-03-22Issue #103: allow Infinity and -Infinity to be parsed.Eric Haszlakiewicz1-1/+51
2014-03-18nan function requires -lm on some platforms; use of NAN is better, if available.Markus Stenberg1-1/+6
2014-03-09Issue#102 - add support for parsing "NaN".Eric Haszlakiewicz1-10/+31
2014-02-11Merge pull request #112 from TazeTSchnitzel/LowercaseLiteralsEric Haszlakiewicz1-32/+46
Only allow lowercase literals in STRICT mode
2014-02-11Fix Issue #111: Fix off-by-one error when range checking the input to ↵Eric Haszlakiewicz1-1/+1
json_tokener_error_desc().
2013-11-14Only allow lowercase literals in STRICT modeAndrea Faulds1-32/+46
2013-09-11Added a json_object_new_double_s() convenience function to allow an exact ↵Eric Haszlakiewicz1-2/+4
string representation of a double to be specified when creating the object and use it in json_tokener_parse_ex() so a re-serialized object more exactly matches the input. Add json_object_free_userdata() and json_object_userdata_to_json_string() too.
2013-09-08Merge pull request #96 from rouault/remove_strdnupEric Haszlakiewicz1-23/+0
Remove redefinition of strndup() which is no longer used in the codebase
2013-09-08Merge pull request #94 from remicollet/issue-strict2Eric Haszlakiewicz1-2/+14
more strictness
2013-09-08Fix potential out-of-bounds read in json_tokener_error_descEven Rouault1-1/+1
Found by Coverity. The number of elements of an array 'ar' is found by sizeof(ar)/sizeof(ar[0]) and not sizeof(ar) 76const char *json_tokener_error_desc(enum json_tokener_error jerr) 77{ 78 int jerr_int = (int)jerr; 1. Condition "jerr_int < 0", taking false branch 2. Condition "jerr_int > 112 /* (int)sizeof (gdal_json_tokener_errors) */", taking false branch 79 if (jerr_int < 0 || jerr_int > (int)sizeof(json_tokener_errors)) 80 return "Unknown error, invalid json_tokener_error value passed to json_tokener_error_desc()"; CID 1076806 (#1 of 1): Out-of-bounds read (OVERRUN)3. overrun-local: Overrunning array "gdal_json_tokener_errors" of 14 8-byte elements at element index 112 (byte offset 896) using index "jerr" (which evaluates to 112). 81 return json_tokener_errors[jerr]; 82}
2013-08-23trailing char not allowed in strict modeRemi Collet1-0/+7
2013-08-21no comment in strict modeRemi Collet1-1/+1
2013-08-12Remove redefinition of strndup() which is no longer used in the codebaseEven Rouault1-23/+0
2013-08-06no single-quote string in strict modeRemi Collet1-1/+6
2013-06-19Minor spell check.Eric Haszlakiewicz1-1/+1
2013-06-13in strick mode, number must not start with 0Remi Collet1-0/+5
2013-03-31Issue #15: add a way to set a JSON_TOKENER_STRICT flag to forbid commas at ↵Eric Haszlakiewicz1-2/+21
the end of arrays and objects.
2013-03-06Fix broken build by using ADVANCE_CHAR macro return.William Dignazio1-3/+7
We forget to check or use the return value of the ADVANCE_CHAR macro, and upon compilation an error is thrown because of its lack of use. This patch checks to see if the macro was successful, and if not replaces the offending character with a replacement.
2013-03-06Rename misnomer POP_CHAR to PEEK_CHAR.William Dignazio1-18/+18
While parsing token data, we use the POP_CHAR macro to 'peek' at character data. This behaviour is noted in the comments for the macro, yet the definition is left as 'pop'. Changing to PEEK_CHAR does not imply that the character being observed is removed.
2013-02-26Merge branch 'remicollet-issue-float'Eric Haszlakiewicz1-1/+17
Conflicts: json_util.c
2013-02-09Enable -Werror and fix a number of minor warnings that existed.Eric Haszlakiewicz1-8/+9
2012-12-23Merge pull request #51 from remicollet/issue-dyndepthEric Haszlakiewicz1-5/+16
Make maximum recursion depth a runtime option
2012-12-13move locale change to be global for perfRemi Collet1-0/+16
2012-12-09Fix issue #53 - ensure explicit length string are still NUL terminated, and ↵Eric Haszlakiewicz1-1/+1
fix json_tokener_parse() to work properly with embedded unicode \u0000 values in strings. Adjust test_null to check for this case. See also http://bugs.debian.org/687269
2012-11-27float parsing must be locale independentRemi Collet1-1/+1
2012-11-27Make maximum recursion depth a runtime optionRemi Collet1-5/+16
2012-07-29Handle the \f escape sequence (the two characters: backslash followed by an ↵Eric Haszlakiewicz1-0/+2
f, not a literal formfeed) and extend the test_parse test to check all valid escape sequences.
2012-05-21Replaced #if HAVE_X with #ifdef HAVE_X as the former test is troublemaker ↵Mateusz Loskot1-1/+7
with #define HAVE_X where #define HAVE_X 1|0 is meant.
2012-04-24Fixed parsing numbers in E notation. `Eric Haszlakiewicz1-1/+2
2012-03-31Fix a bug in json_tokener_parse_ex when re-using the same tokener to parse ↵Eric Haszlakiewicz1-1/+11
multiple objects. Now, json_tokener_reset() does not need to be called after a valid object is parsed.
2012-03-31Perform better error checking in json_tokener_parse_verbose and rewrite ↵Eric Haszlakiewicz1-12/+9
json_tokener_parse to use that instead of json_tokener_parse_ex. Fix a typo in the string represenations of the json_tokener_error_depth error (s/to deep/too deep/)
2012-02-22Add json_tokener_get_error() and json_tokener_error_desc() to better ↵Eric Haszlakiewicz1-0/+13
encapsulate the process of retrieving errors while parsing. Add documentation for the json_tokener_parse_ex() function.
2012-01-18 json_tokener_parse(): avoid possible NULL derefFrederik Deweerdt1-0/+2
2010-12-08add json_tokener_parse_verbose, and return NULL on parser errorsJehiah Czebotar1-1/+17
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@62 327403b1-1117-474d-bef2-5cb71233fd97
2010-12-07Simplify things by storing integer values only as int64_t's internally, andehaszla1-12/+2
omit the range check during parsing since we already have the checks when accessing the value. There is no longer a json_type_int64, only json_type_int. Fix some problems with parsing 0 and -0 values, and add a couple of tests. Fix some minor compile issues on HPUX environments. git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@60 327403b1-1117-474d-bef2-5cb71233fd97
2010-10-06 * Add int64 support. Two new functions json_object_net_int64 andMichael Clark1-6/+18
json_object_get_int64. Binary compatibility preserved. Eric Haszlakiewicz, EHASZLA at transunion com Rui Miguel Silva Seabra, rms at 1407 dot org git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@56 327403b1-1117-474d-bef2-5cb71233fd97
2009-08-20 * Add handling of surrogate pairsBrent Miller1-19/+83
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@53 327403b1-1117-474d-bef2-5cb71233fd97
2009-07-25 * Rename min and max so we can never clash with C or C++ std libraryMichael Clark1-4/+4
Ian Atha, thatha at yahoo-inc dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@43 327403b1-1117-474d-bef2-5cb71233fd97
2009-07-08 Add const qualifier to the json_tokener_parse functionsChristopher Watford1-7/+7
Eric Haszlakiewicz, EHASZLA at transunion dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@42 327403b1-1117-474d-bef2-5cb71233fd97
2009-07-08Erik Hovland (3):Christopher Watford1-0/+1
Fix any noticeable spelling or grammar errors. Make sure every va_start has a va_end. Check all pointers for validity. git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@41 327403b1-1117-474d-bef2-5cb71233fd97
2009-04-27optimizations to json_tokener_parse_ex(), printbuf_memappend()Michael Clark1-92/+197
-- Brent Miller, bdmiller at yahoo dash inc dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@34 327403b1-1117-474d-bef2-5cb71233fd97
2009-02-25 * Don't use this as a variable, so we can compile with a C++ compilerMichael Clark1-2/+4
* Add casts from void* to type of assignment when using malloc * Add #ifdef __cplusplus guards to all of the headers * Add typedefs for json_object, json_tokener, array_list, printbuf, lh_table Michael Clark, <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@33 327403b1-1117-474d-bef2-5cb71233fd97
2009-02-25 * Null pointer dereference fix. Fix json_object_get_boolean strlen testMichael Clark1-0/+3
to not return TRUE for zero length string. Remove redundant includes. Erik Hovland, erik at hovland dot org git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@31 327403b1-1117-474d-bef2-5cb71233fd97