1 https://github.com/json-c/json-c/commit/64e36901a0614bf64a19bc3396469c66dcd0b015
3 * CVE-2013-6371: hash collision denial of service
4 * CVE-2013-6370: buffer overflow if size_t is larger than int
6 diff --git a/Makefile.am b/Makefile.am
7 index 24b9bdf..26ced27 100644
10 @@ -23,7 +23,8 @@ libjson_cinclude_HEADERS = \
18 #libjsonx_includedir = $(libdir)/json-c-@VERSION@
20 @@ -41,7 +42,8 @@ libjson_c_la_SOURCES = \
30 diff --git a/Makefile.am.inc b/Makefile.am.inc
31 index fd68a25..fec591b 100644
35 -AM_CFLAGS = -Wall -Werror -Wextra -Wwrite-strings -Wno-unused-parameter -std=gnu99 -D_GNU_SOURCE -D_REENTRANT
36 +AM_CFLAGS = -Wall -Werror -Wno-error=deprecated-declarations -Wextra -Wwrite-strings -Wno-unused-parameter -std=gnu99 -D_GNU_SOURCE -D_REENTRANT
38 diff --git a/json_object.h b/json_object.h
39 index 1005734..200ac40 100644
43 #ifndef _json_object_h_
44 #define _json_object_h_
47 +#define THIS_FUNCTION_IS_DEPRECATED(func) func __attribute__ ((deprecated))
48 +#elif defined(_MSC_VER)
49 +#define THIS_FUNCTION_IS_DEPRECATED(func) __declspec(deprecated) func
51 +#define THIS_FUNCTION_IS_DEPRECATED(func) func
54 #include "json_inttypes.h"
57 @@ -279,8 +287,8 @@ extern void json_object_object_add(struct json_object* obj, const char *key,
58 * @returns the json_object associated with the given field name
59 * @deprecated Please use json_object_object_get_ex
61 -extern struct json_object* json_object_object_get(struct json_object* obj,
63 +THIS_FUNCTION_IS_DEPRECATED(extern struct json_object* json_object_object_get(struct json_object* obj,
66 /** Get the json_object associated with a given object field.
68 diff --git a/json_tokener.c b/json_tokener.c
69 index a1019c0..19de8ef 100644
72 @@ -81,6 +81,7 @@ static const char* json_tokener_errors[] = {
73 "object value separator ',' expected",
74 "invalid string sequence",
76 + "buffer size overflow"
79 const char *json_tokener_error_desc(enum json_tokener_error jerr)
80 @@ -243,6 +244,16 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
82 tok->err = json_tokener_success;
84 + /* this interface is presently not 64-bit clean due to the int len argument
85 + and the internal printbuf interface that takes 32-bit int len arguments
86 + so the function limits the maximum string size to INT32_MAX (2GB).
87 + If the function is called with len == -1 then strlen is called to check
88 + the string length is less than INT32_MAX (2GB) */
89 + if ((len < -1) || (len == -1 && strlen(str) > INT32_MAX)) {
90 + tok->err = json_tokener_error_size;
94 while (PEEK_CHAR(c, tok)) {
97 diff --git a/json_tokener.h b/json_tokener.h
98 index 5471d97..a72d2bd 100644
101 @@ -33,7 +33,8 @@ enum json_tokener_error {
102 json_tokener_error_parse_object_key_sep,
103 json_tokener_error_parse_object_value_sep,
104 json_tokener_error_parse_string,
105 - json_tokener_error_parse_comment
106 + json_tokener_error_parse_comment,
107 + json_tokener_error_size
110 enum json_tokener_state {
111 @@ -163,6 +164,11 @@ extern void json_tokener_set_flags(struct json_tokener *tok, int flags);
112 * responsible for calling json_tokener_parse_ex with an appropriate str
113 * parameter starting with the extra characters.
115 + * This interface is presently not 64-bit clean due to the int len argument
116 + * so the function limits the maximum string size to INT32_MAX (2GB).
117 + * If the function is called with len == -1 then strlen is called to check
118 + * the string length is less than INT32_MAX (2GB)
122 json_object *jobj = NULL;
123 diff --git a/linkhash.c b/linkhash.c
124 index 5043148..712c387 100644
131 +#ifdef HAVE_ENDIAN_H
132 +# include <endian.h> /* attempt to define endianness */
135 +#include "random_seed.h"
136 #include "linkhash.h"
138 void lh_abort(const char *msg, ...)
139 @@ -39,14 +44,378 @@ int lh_ptr_equal(const void *k1, const void *k2)
144 + * hashlittle from lookup3.c, by Bob Jenkins, May 2006, Public Domain.
145 + * http://burtleburtle.net/bob/c/lookup3.c
146 + * minor modifications to make functions static so no symbols are exported
147 + * minor mofifications to compile with -Werror
151 +-------------------------------------------------------------------------------
152 +lookup3.c, by Bob Jenkins, May 2006, Public Domain.
154 +These are functions for producing 32-bit hashes for hash table lookup.
155 +hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
156 +are externally useful functions. Routines to test the hash are included
157 +if SELF_TEST is defined. You can use this free for any purpose. It's in
158 +the public domain. It has no warranty.
160 +You probably want to use hashlittle(). hashlittle() and hashbig()
161 +hash byte arrays. hashlittle() is is faster than hashbig() on
162 +little-endian machines. Intel and AMD are little-endian machines.
163 +On second thought, you probably want hashlittle2(), which is identical to
164 +hashlittle() except it returns two 32-bit hashes for the price of one.
165 +You could implement hashbig2() if you wanted but I haven't bothered here.
167 +If you want to find a hash of, say, exactly 7 integers, do
168 + a = i1; b = i2; c = i3;
170 + a += i4; b += i5; c += i6;
174 +then use c as the hash value. If you have a variable length array of
175 +4-byte integers to hash, use hashword(). If you have a byte array (like
176 +a character string), use hashlittle(). If you have several byte arrays, or
177 +a mix of things, see the comments above hashlittle().
179 +Why is this so big? I read 12 bytes at a time into 3 4-byte integers,
180 +then mix those integers. This is fast (you can do a lot more thorough
181 +mixing with 12*3 instructions on 3 integers than you can with 3 instructions
182 +on 1 byte), but shoehorning those bytes into integers efficiently is messy.
183 +-------------------------------------------------------------------------------
187 + * My best guess at if you are big-endian or little-endian. This may
190 +#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
191 + __BYTE_ORDER == __LITTLE_ENDIAN) || \
192 + (defined(i386) || defined(__i386__) || defined(__i486__) || \
193 + defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL))
194 +# define HASH_LITTLE_ENDIAN 1
195 +# define HASH_BIG_ENDIAN 0
196 +#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \
197 + __BYTE_ORDER == __BIG_ENDIAN) || \
198 + (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel))
199 +# define HASH_LITTLE_ENDIAN 0
200 +# define HASH_BIG_ENDIAN 1
202 +# define HASH_LITTLE_ENDIAN 0
203 +# define HASH_BIG_ENDIAN 0
206 +#define hashsize(n) ((uint32_t)1<<(n))
207 +#define hashmask(n) (hashsize(n)-1)
208 +#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
211 +-------------------------------------------------------------------------------
212 +mix -- mix 3 32-bit values reversibly.
214 +This is reversible, so any information in (a,b,c) before mix() is
215 +still in (a,b,c) after mix().
217 +If four pairs of (a,b,c) inputs are run through mix(), or through
218 +mix() in reverse, there are at least 32 bits of the output that
219 +are sometimes the same for one pair and different for another pair.
220 +This was tested for:
221 +* pairs that differed by one bit, by two bits, in any combination
222 + of top bits of (a,b,c), or in any combination of bottom bits of
224 +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed
225 + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
226 + is commonly produced by subtraction) look like a single 1-bit
228 +* the base values were pseudorandom, all zero but one bit set, or
229 + all zero plus a counter that starts at zero.
231 +Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that
236 +Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing
237 +for "differ" defined as + with a one-bit base and a two-bit delta. I
238 +used http://burtleburtle.net/bob/hash/avalanche.html to choose
239 +the operations, constants, and arrangements of the variables.
241 +This does not achieve avalanche. There are input bits of (a,b,c)
242 +that fail to affect some output bits of (a,b,c), especially of a. The
243 +most thoroughly mixed value is c, but it doesn't really even achieve
246 +This allows some parallelism. Read-after-writes are good at doubling
247 +the number of bits affected, so the goal of mixing pulls in the opposite
248 +direction as the goal of parallelism. I did what I could. Rotates
249 +seem to cost as much as shifts on every machine I could lay my hands
250 +on, and rotates are much kinder to the top and bottom bits, so I used
252 +-------------------------------------------------------------------------------
254 +#define mix(a,b,c) \
256 + a -= c; a ^= rot(c, 4); c += b; \
257 + b -= a; b ^= rot(a, 6); a += c; \
258 + c -= b; c ^= rot(b, 8); b += a; \
259 + a -= c; a ^= rot(c,16); c += b; \
260 + b -= a; b ^= rot(a,19); a += c; \
261 + c -= b; c ^= rot(b, 4); b += a; \
265 +-------------------------------------------------------------------------------
266 +final -- final mixing of 3 32-bit values (a,b,c) into c
268 +Pairs of (a,b,c) values differing in only a few bits will usually
269 +produce values of c that look totally different. This was tested for
270 +* pairs that differed by one bit, by two bits, in any combination
271 + of top bits of (a,b,c), or in any combination of bottom bits of
273 +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed
274 + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
275 + is commonly produced by subtraction) look like a single 1-bit
277 +* the base values were pseudorandom, all zero but one bit set, or
278 + all zero plus a counter that starts at zero.
280 +These constants passed:
281 + 14 11 25 16 4 14 24
282 + 12 14 25 16 4 14 24
283 +and these came close:
287 +-------------------------------------------------------------------------------
289 +#define final(a,b,c) \
291 + c ^= b; c -= rot(b,14); \
292 + a ^= c; a -= rot(c,11); \
293 + b ^= a; b -= rot(a,25); \
294 + c ^= b; c -= rot(b,16); \
295 + a ^= c; a -= rot(c,4); \
296 + b ^= a; b -= rot(a,14); \
297 + c ^= b; c -= rot(b,24); \
302 +-------------------------------------------------------------------------------
303 +hashlittle() -- hash a variable-length key into a 32-bit value
304 + k : the key (the unaligned variable-length array of bytes)
305 + length : the length of the key, counting by bytes
306 + initval : can be any 4-byte value
307 +Returns a 32-bit value. Every bit of the key affects every bit of
308 +the return value. Two keys differing by one or two bits will have
309 +totally different hash values.
311 +The best hash table sizes are powers of 2. There is no need to do
312 +mod a prime (mod is sooo slow!). If you need less than 32 bits,
313 +use a bitmask. For example, if you need only 10 bits, do
314 + h = (h & hashmask(10));
315 +In which case, the hash table should have hashsize(10) elements.
317 +If you are hashing n strings (uint8_t **)k, do it like this:
318 + for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h);
320 +By Bob Jenkins, 2006. bob_jenkins@burtleburtle.net. You may use this
321 +code any way you wish, private, educational, or commercial. It's free.
323 +Use for hash table lookup, or anything where one collision in 2^^32 is
324 +acceptable. Do NOT use for cryptographic purposes.
325 +-------------------------------------------------------------------------------
328 +static uint32_t hashlittle( const void *key, size_t length, uint32_t initval)
330 + uint32_t a,b,c; /* internal state */
331 + union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */
333 + /* Set up the internal state */
334 + a = b = c = 0xdeadbeef + ((uint32_t)length) + initval;
337 + if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
338 + const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
340 + /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
341 + while (length > 12)
351 + /*----------------------------- handle the last (probably partial) block */
353 + * "k[2]&0xffffff" actually reads beyond the end of the string, but
354 + * then masks off the part it's not allowed to read. Because the
355 + * string is aligned, the masked-off tail is in the same word as the
356 + * rest of the string. Every machine with memory protection I've seen
357 + * does it on word boundaries, so is OK with this. But VALGRIND will
358 + * still catch it and complain. The masking trick does make the hash
359 + * noticably faster for short strings (like English words).
365 + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
366 + case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
367 + case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
368 + case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
369 + case 8 : b+=k[1]; a+=k[0]; break;
370 + case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
371 + case 6 : b+=k[1]&0xffff; a+=k[0]; break;
372 + case 5 : b+=k[1]&0xff; a+=k[0]; break;
373 + case 4 : a+=k[0]; break;
374 + case 3 : a+=k[0]&0xffffff; break;
375 + case 2 : a+=k[0]&0xffff; break;
376 + case 1 : a+=k[0]&0xff; break;
377 + case 0 : return c; /* zero length strings require no mixing */
380 +#else /* make valgrind happy */
382 + const uint8_t *k8 = (const uint8_t *)k;
385 + case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
386 + case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
387 + case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
388 + case 9 : c+=k8[8]; /* fall through */
389 + case 8 : b+=k[1]; a+=k[0]; break;
390 + case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
391 + case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
392 + case 5 : b+=k8[4]; /* fall through */
393 + case 4 : a+=k[0]; break;
394 + case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
395 + case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
396 + case 1 : a+=k8[0]; break;
400 +#endif /* !valgrind */
402 + } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
403 + const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
406 + /*--------------- all but last block: aligned reads and different mixing */
407 + while (length > 12)
409 + a += k[0] + (((uint32_t)k[1])<<16);
410 + b += k[2] + (((uint32_t)k[3])<<16);
411 + c += k[4] + (((uint32_t)k[5])<<16);
417 + /*----------------------------- handle the last (probably partial) block */
418 + k8 = (const uint8_t *)k;
421 + case 12: c+=k[4]+(((uint32_t)k[5])<<16);
422 + b+=k[2]+(((uint32_t)k[3])<<16);
423 + a+=k[0]+(((uint32_t)k[1])<<16);
425 + case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
427 + b+=k[2]+(((uint32_t)k[3])<<16);
428 + a+=k[0]+(((uint32_t)k[1])<<16);
430 + case 9 : c+=k8[8]; /* fall through */
431 + case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
432 + a+=k[0]+(((uint32_t)k[1])<<16);
434 + case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
436 + a+=k[0]+(((uint32_t)k[1])<<16);
438 + case 5 : b+=k8[4]; /* fall through */
439 + case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
441 + case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
446 + case 0 : return c; /* zero length requires no mixing */
449 + } else { /* need to read the key one byte at a time */
450 + const uint8_t *k = (const uint8_t *)key;
452 + /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
453 + while (length > 12)
456 + a += ((uint32_t)k[1])<<8;
457 + a += ((uint32_t)k[2])<<16;
458 + a += ((uint32_t)k[3])<<24;
460 + b += ((uint32_t)k[5])<<8;
461 + b += ((uint32_t)k[6])<<16;
462 + b += ((uint32_t)k[7])<<24;
464 + c += ((uint32_t)k[9])<<8;
465 + c += ((uint32_t)k[10])<<16;
466 + c += ((uint32_t)k[11])<<24;
472 + /*-------------------------------- last block: affect all 32 bits of (c) */
473 + switch(length) /* all the case statements fall through */
475 + case 12: c+=((uint32_t)k[11])<<24;
476 + case 11: c+=((uint32_t)k[10])<<16;
477 + case 10: c+=((uint32_t)k[9])<<8;
479 + case 8 : b+=((uint32_t)k[7])<<24;
480 + case 7 : b+=((uint32_t)k[6])<<16;
481 + case 6 : b+=((uint32_t)k[5])<<8;
483 + case 4 : a+=((uint32_t)k[3])<<24;
484 + case 3 : a+=((uint32_t)k[2])<<16;
485 + case 2 : a+=((uint32_t)k[1])<<8;
496 unsigned long lh_char_hash(const void *k)
498 - unsigned int h = 0;
499 - const char* data = (const char*)k;
501 - while( *data!=0 ) h = h*129 + (unsigned int)(*data++) + LH_PRIME;
502 + static volatile int random_seed = -1;
504 + if (random_seed == -1) {
506 + /* we can't use -1 as it is the unitialized sentinel */
507 + while ((seed = json_c_get_random_seed()) == -1);
508 +#if defined __GNUC__
509 + __sync_val_compare_and_swap(&random_seed, -1, seed);
510 +#elif defined _MSC_VER
511 + InterlockedCompareExchange(&random_seed, seed, -1);
513 +#warning "racy random seed initializtion if used by multiple threads"
514 + random_seed = seed; /* potentially racy */
519 + return hashlittle((const char*)k, strlen((const char*)k), random_seed);
522 int lh_char_equal(const void *k1, const void *k2)
523 diff --git a/linkhash.h b/linkhash.h
524 index 378de0b..950d09f 100644
527 @@ -246,7 +246,7 @@ extern struct lh_entry* lh_table_lookup_entry(struct lh_table *t, const void *k)
528 * @return a pointer to the found value or NULL if it does not exist.
529 * @deprecated Use lh_table_lookup_ex instead.
531 -extern const void* lh_table_lookup(struct lh_table *t, const void *k);
532 +THIS_FUNCTION_IS_DEPRECATED(extern const void* lh_table_lookup(struct lh_table *t, const void *k));
535 * Lookup a record in the table
536 diff --git a/random_seed.c b/random_seed.c
538 index 0000000..3b520d4
545 + * Copyright (c) 2013 Metaparadigm Pte. Ltd.
546 + * Michael Clark <michael@metaparadigm.com>
548 + * This library is free software; you can redistribute it and/or modify
549 + * it under the terms of the MIT license. See COPYING for details.
556 +#define DEBUG_SEED(s)
559 +#if defined ENABLE_RDRAND
563 +#if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
564 +#define HAS_X86_CPUID 1
566 +static void do_cpuid(int regs[], int h)
568 + __asm__ __volatile__(
569 +#if defined __x86_64__
575 +#if defined __x86_64__
580 + : "=a"(regs[0]), [ebx] "=r"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
584 +#elif defined _MSC_VER
586 +#define HAS_X86_CPUID 1
587 +#define do_cpuid __cpuid
595 +static int has_rdrand()
597 + // CPUID.01H:ECX.RDRAND[bit 30] == 1
600 + return (regs[2] & (1 << 30)) != 0;
605 +/* get_rdrand_seed - GCC x86 and X64 */
607 +#if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
609 +#define HAVE_RDRAND 1
611 +static int get_rdrand_seed()
613 + DEBUG_SEED("get_rdrand_seed");
616 + __asm__ __volatile__("1: .byte 0x0F\n"
626 +#if defined _MSC_VER
628 +#if _MSC_VER >= 1700
629 +#define HAVE_RDRAND 1
631 +/* get_rdrand_seed - Visual Studio 2012 and above */
633 +static int get_rdrand_seed()
635 + DEBUG_SEED("get_rdrand_seed");
637 + while (_rdrand32_step(&r) == 0);
641 +#elif defined _M_IX86
642 +#define HAVE_RDRAND 1
644 +/* get_rdrand_seed - Visual Studio 2010 and below - x86 only */
646 +static int get_rdrand_seed()
648 + DEBUG_SEED("get_rdrand_seed");
652 + __asm _emit 0x0F __asm _emit 0xC7 __asm _emit 0xF0
654 + __asm mov _eax, eax
661 +#endif /* defined ENABLE_RDRAND */
664 +/* has_dev_urandom */
666 +#if defined (__APPLE__) || defined(__unix__) || defined(__linux__)
673 +#include <sys/stat.h>
675 +#define HAVE_DEV_RANDOM 1
677 +static const char *dev_random_file = "/dev/urandom";
679 +static int has_dev_urandom()
682 + if (stat(dev_random_file, &buf)) {
685 + return ((buf.st_mode & S_IFCHR) != 0);
689 +/* get_dev_random_seed */
691 +static int get_dev_random_seed()
693 + DEBUG_SEED("get_dev_random_seed");
695 + int fd = open(dev_random_file, O_RDONLY);
697 + fprintf(stderr, "error opening %s: %s", dev_random_file, strerror(errno));
702 + ssize_t nread = read(fd, &r, sizeof(r));
703 + if (nread != sizeof(r)) {
704 + fprintf(stderr, "error read %s: %s", dev_random_file, strerror(errno));
707 + else if (nread != sizeof(r)) {
708 + fprintf(stderr, "error short read %s", dev_random_file);
718 +/* get_cryptgenrandom_seed */
722 +#define HAVE_CRYPTGENRANDOM 1
724 +#include <windows.h>
725 +#pragma comment(lib, "advapi32.lib")
727 +static int get_cryptgenrandom_seed()
729 + DEBUG_SEED("get_cryptgenrandom_seed");
731 + HCRYPTPROV hProvider = 0;
734 + if (!CryptAcquireContextW(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
735 + fprintf(stderr, "error CryptAcquireContextW");
739 + if (!CryptGenRandom(hProvider, sizeof(r), (BYTE*)&r)) {
740 + fprintf(stderr, "error CryptGenRandom");
744 + CryptReleaseContext(hProvider, 0);
756 +static int get_time_seed()
758 + DEBUG_SEED("get_time_seed");
760 + return (int)time(NULL) * 433494437;
764 +/* json_c_get_random_seed */
766 +int json_c_get_random_seed()
769 + if (has_rdrand()) return get_rdrand_seed();
772 + if (has_dev_urandom()) return get_dev_random_seed();
774 +#if HAVE_CRYPTGENRANDOM
775 + return get_cryptgenrandom_seed();
777 + return get_time_seed();
779 diff --git a/random_seed.h b/random_seed.h
781 index 0000000..7362d67
788 + * Copyright (c) 2013 Metaparadigm Pte. Ltd.
789 + * Michael Clark <michael@metaparadigm.com>
791 + * This library is free software; you can redistribute it and/or modify
792 + * it under the terms of the MIT license. See COPYING for details.
803 +extern int json_c_get_random_seed();
813 --- a/config.h.in 2013-04-03 04:04:18.000000000 +0200
814 +++ b/config.h.in 2014-04-10 10:32:09.318409377 +0200
816 /* Define if .gnu.warning accepts long strings. */
817 #undef HAS_GNU_WARNING_LONG
819 +/* Enable RDRANR Hardware RNG Hash Seed */
820 +#undef ENABLE_RDRAND
822 /* Define to 1 if you have the <dlfcn.h> header file. */
825 /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
828 +/* Define to 1 if you have the <endian.h> header file. */
829 +#undef HAVE_ENDIAN_H
831 /* Define to 1 if you have the <fcntl.h> header file. */
834 --- a/configure.in 2014-04-10 10:32:56.443006786 +0200
835 +++ b/configure.in 2014-04-10 10:34:26.480080755 +0200
838 AM_CONDITIONAL(ENABLE_OLDNAME_COMPAT, [test "x${enable_oldname_compat}" != "xno"])
840 +AC_ARG_ENABLE(rdrand,
841 + AS_HELP_STRING([--enable-rdrand],
842 + [Enable RDRAND Hardware RNG Hash Seed generation on supported x86/x64 platforms.]),
843 + [if test x$enableval = xyes; then
845 + AC_DEFINE(ENABLE_RDRAND, 1, [Enable RDRANR Hardware RNG Hash Seed])
848 +if test "x$enable_rdrand" = "xyes"; then
849 + AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed enabled on supported x86/x64 platforms])
851 + AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed disabled. Use --enable-rdrand to enable])
854 # Checks for programs.
856 # Checks for libraries.
858 AC_CONFIG_HEADER(config.h)
859 AC_CONFIG_HEADER(json_config.h)
861 -AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/cdefs.h] [sys/param.h] stdarg.h locale.h)
862 +AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/cdefs.h] [sys/param.h] stdarg.h locale.h endian.h)
863 AC_CHECK_HEADER(inttypes.h,[AC_DEFINE([JSON_C_HAVE_INTTYPES_H],[1],[Public define for json_inttypes.h])])
865 # Checks for typedefs, structures, and compiler characteristics.