Commit Graph

35 Commits

Author SHA1 Message Date
Michael Clark
64e36901a0 Patch to address the following issues:
* CVE-2013-6371: hash collision denial of service
* CVE-2013-6370: buffer overflow if size_t is larger than int
2014-04-09 13:48:21 +08:00
Eric Haszlakiewicz
51993c28c2 Added a json_object_new_double_s() convenience function to allow an exact 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-11 20:27:39 -05:00
Even Rouault
6c4bb3840c Add extern to json_object_set_serializer so that it gets exported (Windows fix) 2013-08-11 01:18:17 +02:00
Greg Hazel
88bf1c9960 one definition of json_object_object_foreach only works on c99 and later 2013-03-19 16:26:12 -07:00
Eric Haszlakiewicz
5b36a432c8 Merge branch 'remicollet-issue-float'
Conflicts:
	json_util.c
2013-02-26 21:09:10 -06:00
Eric Haszlakiewicz
9b64c05ff9 Mark the "val" variable in json_object_object_foreach as unused so the compiler doesn't complain. Fix warnings in the testReplaceExisting test. 2013-02-21 12:32:29 -06:00
Eric Haszlakiewicz
92d289f5d3 Add a comment briefly describing json_object_object_length() 2013-02-09 16:18:05 -06:00
Greg Hazel
cca74c6de6 add json_object_object_length 2013-01-11 01:36:55 -08:00
Alexander Klauer
beb12d49e1 Make macro json_object_object_foreach multiple-use safe 2012-12-19 10:31:39 +01:00
Remi Collet
32d149c8f6 probably worth an option for this 2012-12-13 11:46:04 +01:00
Eric Haszlakiewicz
f6b27cbb6c Make it safe to delete keys while iterating with the json_object_object_foreach macro. 2012-10-20 20:26:37 -05:00
Eric Haszlakiewicz
5abc0ea444 Reformat the json_object_object_foreach macro so it is readable, and document what is allowed to be done with the object while iterating. 2012-10-20 20:10:15 -05:00
Eric Haszlakiewicz
5f4739e2eb Change json_object_put to return 1 if the object passed was actually freed. (or 0 if only the reference count was decremented) 2012-10-18 17:10:09 -05:00
Eric Haszlakiewicz
38f421a2e7 Add a json_set_serializer() function to allow the string output of a json_object to be customized. 2012-09-02 15:21:56 -05:00
Eric Haszlakiewicz
3fcffe1bb0 Add a json_object_to_json_string_ext() function to allow the formatting of output to be selected.
There are now three options: JSON_C_TO_STRING_SPACED, JSON_C_TO_STRING_PLAIN and JSON_C_TO_STRING_PRETTY.
This also add a json_object_to_file_ext() that takes the same flags.
Existing output of json_object_to_json_string() is unchanged, and uses JSON_C_TO_STRING_SPACED.
Thanks fo Grant Edwards for the initial patches.
2012-04-28 13:26:09 -05:00
Keith Derrick
6917586acf Add NULL-safe get object method
New json_object_object_get_ex() method protects itself against null pointers
and invalid objects being passed in.
2012-04-12 11:50:08 -07:00
Keith Derrick
ca519fb817 Added explanatory notes to documentation. 2012-04-05 19:54:12 -07:00
Eric Haszlakiewicz
6ff0817bac Mention json_type_to_name() in the docs for json_object_get_type(). 2012-03-31 22:47:47 -05:00
Eric Haszlakiewicz
aef439a175 Adjust json_object_is_type and json_object_get_type so they return json_type_null for NULL objects. 2012-03-31 13:47:28 -05:00
Keith Derrick
37e7467476 Rename boolean type to json_bool
In building large systems, there are often clashes over the
preferred base type to use for bool/boolean. At least one
experience has been with a 3rd party proprietary library which
can not be changed. In that case, boolean was a synonym for
unsigned char and used widely in packed structures.
2012-03-26 14:29:31 -07:00
Eric Haszlakiewicz
b21b137805 Include json_inttypes.h in json_object.h since we use types like int32_t in the API and some systems need that header to compile.
As part of this create a public json_config.h with a custom define to
decide whether to include inttypes.h to avoid conflicting with other
projects config.h header.
2012-02-15 20:47:11 -06:00
Frederik Deweerdt
c43871c866 Add new json_object_array_sort function
- uses libc's qsort to sort the arraylist
 - add test in test1.c
2011-10-07 21:07:18 +02:00
Jehiah Czebotar
43d2f417c7 move definition of json_object_iter to public header to enable external use of json_object_object_foreachC
Patch from Rick Moran <https://github.com/DrHayt>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@74 327403b1-1117-474d-bef2-5cb71233fd97
2011-05-25 04:49:20 +00:00
Eric Haszlakiewicz
886c4fbebf Add a json_type_to_name() function which returns a string that describes the type. Useful for logging.
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@67 327403b1-1117-474d-bef2-5cb71233fd97
2011-05-03 20:40:49 +00:00
Jehiah Czebotar
ac601b5b5f update json_object_new_string_len, json_escape_str (internal). Writer handles \x00 correctly
Added parse_null test. This does not change anything with how the parser handles \u0000 or null characters

This commit is addapted from one by Adomas Paltanavičius <adomas@leanholding.com>



git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@63 327403b1-1117-474d-bef2-5cb71233fd97
2011-01-14 17:23:06 +00:00
ehaszla
252669cee6 Simplify things by storing integer values only as int64_t's internally, and
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-12-07 18:15:35 +00:00
Michael Clark
c4dceae1c5 * Add int64 support. Two new functions json_object_net_int64 and
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
2010-10-06 16:39:20 +00:00
Michael Clark
aaec1ef3c5 * Don't use this as a variable, so we can compile with a C++ compiler
* 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 02:31:32 +00:00
Michael Clark
e6548a3dc2 fix typo in json_object.h
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@28 327403b1-1117-474d-bef2-5cb71233fd97
2009-01-10 13:58:06 +00:00
Michael Clark
68cafad078 Add const correctness to public interfaces
Gerard Krol, g dot c dot krol at student dot tudelft dot nl

Update version number to 0.9



git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@27 327403b1-1117-474d-bef2-5cb71233fd97
2009-01-06 22:56:57 +00:00
Michael Clark
14862b1ef3 Patch allows for json-c compile with -Werror and not fail due to
-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
Geoffrey Young, geoff at modperlcookbook dot org



git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@20 327403b1-1117-474d-bef2-5cb71233fd97
2007-12-07 02:50:42 +00:00
Michael Clark
837240f75f * Fix bug in escaping of control characters
Johan Bj�rklund, johbjo09 at kth dot se
  * Remove include "config.h" from headers (should only
    be included from .c files)
    Michael Clark <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@12 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:25 +00:00
Michael Clark
f6a6e486ff * Make headers C++ compatible by change *this to *obj
* Add ifdef C++ extern "C" to headers
  * Use simpler definition of min and max in bits.h
    Larry Lansing, llansing at fuzzynerd dot com

  * Remove automake 1.6 requirement
  * Move autogen commands into autogen.sh. Update README
  * Remove error pointer special case for Windows
  * Change license from LGPL to MIT
    Michael Clark <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@10 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:23 +00:00
Michael Clark
4504df7117 * printbuf.c - C. Watford (christopher dot watford at gmail dot com)
Added a Win32/Win64 compliant implementation of vasprintf
  * debug.c - C. Watford (christopher dot watford at gmail dot com)
    Removed usage of vsyslog on Win32/Win64 systems, needs to be handled
    by a configure script
  * json_object.c - C. Watford (christopher dot watford at gmail dot com)
    Added scope operator to wrap usage of json_object_object_foreach, this
    needs to be rethought to be more ANSI C friendly
  * json_object.h - C. Watford (christopher dot watford at gmail dot com)
    Added Microsoft C friendly version of json_object_object_foreach
  * json_tokener.c - C. Watford (christopher dot watford at gmail dot com)
    Added a Win32/Win64 compliant implementation of strndup
  * json_util.c - C. Watford (christopher dot watford at gmail dot com)
    Added cast and mask to suffice size_t v. unsigned int conversion
    correctness
  * json_tokener.c - sign reversal issue on error info for nested object parse
    spotted by Johan Bj�rklund (johbjo09 at kth.se)
  * json_object.c - escape " in json_escape_str
  * Change to automake and libtool to build shared and static library
    Michael Clark <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@4 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:20 +00:00
Michael Clark
f0d08887b8 import of version 0.1
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@2 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:18 +00:00