Commit Graph

344 Commits

Author SHA1 Message Date
Denis Ahrens
067dc50efe changed code from while to do/while 2015-10-12 16:11:56 +02:00
Jonas Jonsson
e89538f685 Format %x expects unsigned int, not int
Be more explicit that a cast is happening.
2015-10-05 14:00:44 +02:00
Jonas Jonsson
f7331c7194 Use sizeof(seq) instead of magic number 13
Be more future proof by keeping the number of magic constants low.
2015-10-05 13:59:09 +02:00
OlehKulykov
8f2298bad8 Buildable with MS Compiler version >= 1900 2015-08-31 23:43:29 +02:00
Petri Lehtinen
4c4f692bd6 Add json_object_foreach_safe
Fixes #230.
2015-08-26 17:32:55 +03:00
Folkert van Heusden
5d42e1520a Optimized dump_indent to reduce the number of fwrite calls. 2015-05-01 15:18:53 +02:00
Haldean
95dd927857 use snprintf and strncpy in place of sprintf and strcpy
This is both good practice and nice for OpenBSD users, who will no
longer get the nag message to not use sprintf/strcpy every time they
link against jansson. It's worth noting that the existing code seems
safe to me - bounds checks were already happening before the actual
calls - and that this is for extra security.
2015-04-30 00:11:25 -07:00
Petri Lehtinen
11813f4128 Fix a use after free 2015-02-07 07:36:29 +02:00
Petri Lehtinen
890760b2fb Increase test coverage 2014-12-19 08:35:46 +02:00
Petri Lehtinen
5508ab403d Honor JSON_DECODE_INT_AS_REAL at lexical stage
This has the consequence that numbers are never converted to integers
when JSON_DECODE_INT_AS_REAL is set, and thus it works correctly all
integers that are representable as double.

Fixes #212.
2014-12-18 15:16:14 +02:00
Petri Lehtinen
abaae7630e Make it possible to set initial hashtable size
Fixes #213.
2014-12-18 14:43:44 +02:00
Petri Lehtinen
3c9e5c9925 Move the list member to the top of hashtable_pair struct
This may make debugging easier with limited debuggers.
2014-12-10 07:41:41 +02:00
Petri Lehtinen
1c38ab17f5 Include jansson_config.h with quotes
Fixes #209.
2014-12-04 10:45:26 +02:00
Shawn Harris
9b435df3d4 Warnings - use size_t where appropriate to prevent warning when compilation is targeting 64 bit 2014-11-28 18:11:26 -07:00
Petri Lehtinen
ee27b7e3dd jansson 2.7 2014-10-02 13:10:45 +03:00
Petri Lehtinen
fa20e80860 Parse subnormal numbers correctly
Fixes #202.
2014-08-27 07:59:52 +03:00
Petri Lehtinen
88943b64e3 Define JSON_MAX_INDENT
Fixes #191.
2014-07-07 11:34:50 +03:00
Oleg Efimov
541cdf5960 Remove unneeded undef 2014-05-05 15:40:41 +04:00
Oleg Efimov
fc6e314498 Enable usage of AddressSanitizer to check Jansson 2014-05-04 00:34:08 +04:00
Petri Lehtinen
17b5fdd94b Add JSON_REAL_PRECISION
Fixes #178.
2014-04-30 12:46:34 +03:00
Petri Lehtinen
a425f8c650 Rename variables to work aroung a GCC bug on Solaris
Fixes #175.
2014-04-23 12:17:14 +03:00
Karl Lew
571617ebfc use __sun instead of sun 2014-04-08 15:57:58 +00:00
Karl Lew
33e4988180 SmartOS build fix 2014-04-06 04:28:52 +00:00
Petri Lehtinen
49fc6b1194 Merge pull request #163 from vincentbernat/fix/unpack-mix-optional-and-strict
Fix unpack when mixing strict mode and optional keys
2014-02-16 22:09:41 +02:00
Vincent Bernat
56a50e147d Micro-optimization for JSON_STRICT when no optional key is used
The previous commit introduced a loop on all input keys to check the
strict mode. We can avoid this if we don't expect an optional key. In
this case, we fallback to the previous method to compare the length of
the set of expected keys and the length of the parsed keys.
2014-02-15 17:44:02 +01:00
Vincent Bernat
7a0b9af662 Allow to mix JSON_STRICT with optional keys
On unpack, one may want to mix `JSON_STRICT` and optional keys by using
a format like `{s:i,s?o!}`. Unfortunately, this fails the stric test
with `-1 object item(s) left unpacked` error when the second key is not
specified.

To fix that, we iter on each key and we check if we have successfully
unpacked them. This is less efficient than the previous method but it
brings correctness.
2014-02-15 17:40:22 +01:00
nmlgc
4fbe44605b Three fixes for hashtable seeding on Windows
First, wrap "advapi32.dll" into the TEXT() macro. If UNICODE is defined,
GetModuleHandle() redirects to GetModuleHandleW(), which excepts a wchar_t*
UTF-16 parameter, thus causing a compile error. TEXT() prefixes the string
literal with L in this case, and does nothing otherwise.

Second, make sure that CryptGenRandom() is actually called through the function
pointer retrieved by the call to GetProcAddress() above.

And third, replace _getpid() with the equivalent and more ubiquitous Win32 API
function GetCurrentProcessId(). Since _getpid() is not exported by all C
runtimes on Windows (most notably the Driver Development Kit), using it might
introduce previously unneeded runtime dependencies. GetCurrentProcessId(), on
the other hand, has been available in kernel32.dll since at least Windows 95,
just like the other API functions used in this code (GetModuleHandle() and
GetProcAddress()).
2014-02-15 17:11:11 +01:00
Petri Lehtinen
3f5acaa3fb Merge branch '2.6' 2014-02-11 15:15:00 +02:00
Petri Lehtinen
42016a35c8 Oops, ATOMIC_ACQ_REL is not a correct memmodel for __atomic_store_n 2014-02-11 15:14:47 +02:00
Petri Lehtinen
17ec22f514 Merge branch '2.6' 2014-02-11 14:49:15 +02:00
Petri Lehtinen
e83ded066a jansson 2.6 2014-02-11 09:45:30 +02:00
Petri Lehtinen
8f80c2d838 CVE-2013-6401: Change hash function, randomize hashes
Thanks to Florian Weimer and Eric Sesterhenn for reporting, reviewing
and testing.
2014-02-11 08:41:30 +02:00
Petri Lehtinen
30fdf6067e Update copyrights for 2014 2014-01-28 09:16:05 +02:00
Joakim Soderberg
3fe8f74e7f Renamed config.h -> jansson_private_config.h
This is because it's really easy to get a name collission if compiling
Jansson as a subproject in a larger CMake project. If one project includes
several subprojects each having their own config.h, this will cause the
wrong file to be loaded.
2014-01-27 12:48:52 +01:00
nmlgc
98610bfcec Check for key == NULL in json_object_get and json_object_del 2013-12-28 06:11:49 +01:00
Petri Lehtinen
05f7d30e5a Add json_boolean_value as alias for json_is_true
Fixes #146.
2013-12-04 09:14:19 +02:00
Petri Lehtinen
30a4c88843 Fix an off-by-one error 2013-10-15 08:49:40 +03:00
Petri Lehtinen
08be94e8e6 Don't call strlen twice
Oops.
2013-10-15 08:46:17 +03:00
Petri Lehtinen
d544852ff6 Avoid integer overflows with very long strings 2013-10-15 08:44:04 +03:00
Chip Salzenberg
a76dc45512 paper bag bug: json_string_set* functions should set the length too 2013-10-03 19:07:20 -07:00
Chip Salzenberg
6ebd0bc7a6 fix type mismatch anywhere int != int32 (Vorne) 2013-09-30 16:56:01 -07:00
Petri Lehtinen
1bfc33362e Add JSON_ALLOW_NUL decoding flag for enabling NUL byte support 2013-09-30 10:45:02 +03:00
Petri Lehtinen
4d5aead31c Fix NUL byte check for object keys 2013-09-30 10:45:02 +03:00
Petri Lehtinen
78a80b8899 load.c: Change an error message 2013-09-30 09:24:36 +03:00
Chip Salzenberg
6c1ce27095 add new public functions to jansson.def 2013-09-29 16:57:23 -07:00
Chip Salzenberg
dcaa90d21e dump \u sequences as upper case for readability (just like error messages) 2013-09-27 17:32:25 -07:00
Chip Salzenberg
9c259c07aa Support \u0000 - add size_t string lengths to API, load and dump \u000, etc.
Also:
  Steal strings during parsing for half the mallocs!
  Change all input-caused assertions to errors.  No crashes please, we're programmers.
2013-09-27 17:32:06 -07:00
Petri Lehtinen
641002da37 jansson 2.5 2013-09-19 21:26:46 +03:00
Olivier Langlois
21599b95f8 Replace strcpy with memcpy
Since len is known, the copy function does not need to check byte by byte
the end of the string.

Signed-off-by: Olivier Langlois <olivier@olivierlanglois.net>
2013-08-27 22:47:18 -04:00
Petri Lehtinen
3196ad48ed pack: Add format specifiers s#, + and +# 2013-08-14 21:54:11 +03:00