Update to 2.8.

This commit is contained in:
Vanilla I. Shu 2016-09-02 05:17:16 +00:00
parent 5dc98fcb92
commit f7a2e12c38
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=421251
8 changed files with 67 additions and 118 deletions

View File

@ -2,8 +2,7 @@
# $FreeBSD$
PORTNAME= jansson
PORTVERSION= 2.7
PORTREVISION= 3
PORTVERSION= 2.8
CATEGORIES= devel
MASTER_SITES= http://www.digip.org/jansson/releases/

View File

@ -1,2 +1,3 @@
SHA256 (jansson-2.7.tar.bz2) = 459f2b7cf22fb676286723f26169a17cf111fbfb6f54e3dc2ec6b6f9f4a97bdc
SIZE (jansson-2.7.tar.bz2) = 357335
TIMESTAMP = 1472781275
SHA256 (jansson-2.8.tar.bz2) = cf4682f317e2cb3cd69090c8602771a93effd43ea5970cf1444f542af9c631c4
SIZE (jansson-2.8.tar.bz2) = 349617

View File

@ -1,51 +0,0 @@
--- src/jansson_config.h.in.orig 2016-05-16 10:22:34.333432000 +0800
+++ src/jansson_config.h.in 2016-05-16 10:23:18.042096000 +0800
@@ -36,4 +36,8 @@
otherwise to 0. */
#define JSON_HAVE_LOCALECONV @json_have_localeconv@
+/* Maximum recursion depth for parsing JSON input.
+ This limits the depth of e.g. array-within-array constructions. */
+#define JSON_PARSER_MAX_DEPTH 2048
+
#endif
--- src/load.c.orig 2014-10-02 12:59:26.000000000 +0800
+++ src/load.c 2016-05-16 10:21:41.006239000 +0800
@@ -61,6 +61,7 @@ typedef struct {
typedef struct {
stream_t stream;
strbuffer_t saved_text;
+ size_t depth;
int token;
union {
struct {
@@ -800,6 +801,12 @@ static json_t *parse_value(lex_t *lex, s
json_t *json;
double value;
+ lex->depth++;
+ if(lex->depth > JSON_PARSER_MAX_DEPTH) {
+ error_set(error, lex, "maximum parsing depth reached");
+ return NULL;
+ }
+
switch(lex->token) {
case TOKEN_STRING: {
const char *value = lex->value.string.val;
@@ -870,6 +877,7 @@ static json_t *parse_value(lex_t *lex, s
if(!json)
return NULL;
+ lex->depth--;
return json;
}
@@ -877,6 +885,8 @@ static json_t *parse_json(lex_t *lex, si
{
json_t *result;
+ lex->depth = 0;
+
lex_scan(lex, error);
if(!(flags & JSON_DECODE_ANY)) {
if(lex->token != '[' && lex->token != '{') {

View File

@ -1,56 +1,56 @@
--- src/hashtable.c.orig 2014-02-11 15:53:06.000000000 +0800
+++ src/hashtable.c 2014-02-15 18:45:56.864995487 +0800
@@ -103,10 +103,10 @@ static int hashtable_do_del(hashtable_t
--- src/hashtable.c.orig 2016-08-25 17:21:36 UTC
+++ src/hashtable.c
@@ -108,10 +108,10 @@ static int hashtable_do_del(hashtable_t
{
pair_t *pair;
bucket_t *bucket;
- size_t index;
+ size_t ind;
+ size_t idx;
- index = hash & hashmask(hashtable->order);
- bucket = &hashtable->buckets[index];
+ ind = hash & hashmask(hashtable->order);
+ bucket = &hashtable->buckets[ind];
+ idx = hash & hashmask(hashtable->order);
+ bucket = &hashtable->buckets[idx];
pair = hashtable_find_pair(hashtable, bucket, key, hash);
if(!pair)
@@ -148,7 +148,7 @@ static int hashtable_do_rehash(hashtable
@@ -154,7 +154,7 @@ static int hashtable_do_rehash(hashtable
{
list_t *list, *next;
pair_t *pair;
- size_t i, index, new_size;
+ size_t i, ind, new_size;
- size_t i, index, new_size, new_order;
+ size_t i, idx, new_size, new_order;
struct hashtable_bucket *new_buckets;
jsonp_free(hashtable->buckets);
@@ -171,8 +171,8 @@ static int hashtable_do_rehash(hashtable
new_order = hashtable->order + 1;
@@ -180,8 +180,8 @@ static int hashtable_do_rehash(hashtable
for(; list != &hashtable->list; list = next) {
next = list->next;
pair = list_to_pair(list);
- index = pair->hash % new_size;
- insert_to_bucket(hashtable, &hashtable->buckets[index], &pair->list);
+ ind = pair->hash % new_size;
+ insert_to_bucket(hashtable, &hashtable->buckets[ind], &pair->list);
+ idx = pair->hash % new_size;
+ insert_to_bucket(hashtable, &hashtable->buckets[idx], &pair->list);
}
return 0;
@@ -212,7 +212,7 @@ int hashtable_set(hashtable_t *hashtable
@@ -220,7 +220,7 @@ int hashtable_set(hashtable_t *hashtable
{
pair_t *pair;
bucket_t *bucket;
- size_t hash, index;
+ size_t hash, ind;
+ size_t hash, idx;
/* rehash if the load ratio exceeds 1 */
if(hashtable->size >= hashsize(hashtable->order))
@@ -220,8 +220,8 @@ int hashtable_set(hashtable_t *hashtable
@@ -228,8 +228,8 @@ int hashtable_set(hashtable_t *hashtable
return -1;
hash = hash_str(key);
- index = hash & hashmask(hashtable->order);
- bucket = &hashtable->buckets[index];
+ ind = hash & hashmask(hashtable->order);
+ bucket = &hashtable->buckets[ind];
+ idx = hash & hashmask(hashtable->order);
+ bucket = &hashtable->buckets[idx];
pair = hashtable_find_pair(hashtable, bucket, key, hash);
if(pair)

View File

@ -1,33 +1,33 @@
--- src/jansson.h.orig 2013-09-25 06:11:34.000000000 +0800
+++ src/jansson.h 2013-09-25 06:13:20.000000000 +0800
@@ -148,10 +148,10 @@ int json_object_iter_set_new(json_t *obj
key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key))))
--- src/jansson.h.orig 2016-08-26 17:37:02 UTC
+++ src/jansson.h
@@ -159,10 +159,10 @@ int json_object_iter_set_new(json_t *obj
key = json_object_iter_key(n), \
n = json_object_iter_next(object, json_object_key_to_iter(key)))
-#define json_array_foreach(array, index, value) \
- for(index = 0; \
- index < json_array_size(array) && (value = json_array_get(array, index)); \
- index++)
+#define json_array_foreach(array, ind, value) \
+ for(ind = 0; \
+ ind < json_array_size(array) && (value = json_array_get(array, ind)); \
+ ind++)
+#define json_array_foreach(array, idx, value) \
+ for(idx = 0; \
+ idx < json_array_size(array) && (value = json_array_get(array, idx)); \
+ idx++)
static JSON_INLINE
int json_object_set(json_t *object, const char *key, json_t *value)
@@ -172,11 +172,11 @@ int json_object_iter_set(json_t *object,
@@ -183,11 +183,11 @@ int json_object_iter_set(json_t *object,
}
size_t json_array_size(const json_t *array);
-json_t *json_array_get(const json_t *array, size_t index);
-int json_array_set_new(json_t *array, size_t index, json_t *value);
+json_t *json_array_get(const json_t *array, size_t ind);
+int json_array_set_new(json_t *array, size_t ind, json_t *value);
+json_t *json_array_get(const json_t *array, size_t idx);
+int json_array_set_new(json_t *array, size_t idx, json_t *value);
int json_array_append_new(json_t *array, json_t *value);
-int json_array_insert_new(json_t *array, size_t index, json_t *value);
-int json_array_remove(json_t *array, size_t index);
+int json_array_insert_new(json_t *array, size_t ind, json_t *value);
+int json_array_remove(json_t *array, size_t ind);
+int json_array_insert_new(json_t *array, size_t idx, json_t *value);
+int json_array_remove(json_t *array, size_t idx);
int json_array_clear(json_t *array);
int json_array_extend(json_t *array, json_t *other);

View File

@ -1,5 +1,5 @@
--- src/utf.h.orig 2014-10-13 20:43:43.714736504 +0800
+++ src/utf.h 2014-10-13 20:43:55.760735241 +0800
--- src/utf.h.orig 2015-03-07 07:02:40 UTC
+++ src/utf.h
@@ -16,6 +16,8 @@
#include <stdint.h>
#endif

View File

@ -1,11 +1,11 @@
--- src/value.c.orig 2013-09-25 06:13:36.000000000 +0800
+++ src/value.c 2013-09-25 06:15:37.000000000 +0800
@@ -360,20 +360,20 @@ size_t json_array_size(const json_t *jso
--- src/value.c.orig 2016-08-25 17:21:36 UTC
+++ src/value.c
@@ -375,20 +375,20 @@ size_t json_array_size(const json_t *jso
return json_to_array(json)->entries;
}
-json_t *json_array_get(const json_t *json, size_t index)
+json_t *json_array_get(const json_t *json, size_t ind)
+json_t *json_array_get(const json_t *json, size_t idx)
{
json_array_t *array;
if(!json_is_array(json))
@ -13,24 +13,24 @@
array = json_to_array(json);
- if(index >= array->entries)
+ if(ind >= array->entries)
+ if(idx >= array->entries)
return NULL;
- return array->table[index];
+ return array->table[ind];
+ return array->table[idx];
}
-int json_array_set_new(json_t *json, size_t index, json_t *value)
+int json_array_set_new(json_t *json, size_t ind, json_t *value)
+int json_array_set_new(json_t *json, size_t idx, json_t *value)
{
json_array_t *array;
@@ -387,14 +387,14 @@ int json_array_set_new(json_t *json, siz
@@ -402,14 +402,14 @@ int json_array_set_new(json_t *json, siz
}
array = json_to_array(json);
- if(index >= array->entries)
+ if(ind >= array->entries)
+ if(idx >= array->entries)
{
json_decref(value);
return -1;
@ -38,73 +38,73 @@
- json_decref(array->table[index]);
- array->table[index] = value;
+ json_decref(array->table[ind]);
+ array->table[ind] = value;
+ json_decref(array->table[idx]);
+ array->table[idx] = value;
return 0;
}
@@ -466,7 +466,7 @@ int json_array_append_new(json_t *json,
@@ -481,7 +481,7 @@ int json_array_append_new(json_t *json,
return 0;
}
-int json_array_insert_new(json_t *json, size_t index, json_t *value)
+int json_array_insert_new(json_t *json, size_t ind, json_t *value)
+int json_array_insert_new(json_t *json, size_t idx, json_t *value)
{
json_array_t *array;
json_t **old_table;
@@ -480,7 +480,7 @@ int json_array_insert_new(json_t *json,
@@ -495,7 +495,7 @@ int json_array_insert_new(json_t *json,
}
array = json_to_array(json);
- if(index > array->entries) {
+ if(ind > array->entries) {
+ if(idx > array->entries) {
json_decref(value);
return -1;
}
@@ -492,21 +492,21 @@ int json_array_insert_new(json_t *json,
@@ -507,21 +507,21 @@ int json_array_insert_new(json_t *json,
}
if(old_table != array->table) {
- array_copy(array->table, 0, old_table, 0, index);
- array_copy(array->table, index + 1, old_table, index,
- array->entries - index);
+ array_copy(array->table, 0, old_table, 0, ind);
+ array_copy(array->table, ind + 1, old_table, ind,
+ array->entries - ind);
+ array_copy(array->table, 0, old_table, 0, idx);
+ array_copy(array->table, idx + 1, old_table, idx,
+ array->entries - idx);
jsonp_free(old_table);
}
else
- array_move(array, index + 1, index, array->entries - index);
+ array_move(array, ind + 1, ind, array->entries - ind);
+ array_move(array, idx + 1, idx, array->entries - idx);
- array->table[index] = value;
+ array->table[ind] = value;
+ array->table[idx] = value;
array->entries++;
return 0;
}
-int json_array_remove(json_t *json, size_t index)
+int json_array_remove(json_t *json, size_t ind)
+int json_array_remove(json_t *json, size_t idx)
{
json_array_t *array;
@@ -514,14 +514,14 @@ int json_array_remove(json_t *json, size
@@ -529,14 +529,14 @@ int json_array_remove(json_t *json, size
return -1;
array = json_to_array(json);
- if(index >= array->entries)
+ if(ind >= array->entries)
+ if(idx >= array->entries)
return -1;
- json_decref(array->table[index]);
+ json_decref(array->table[ind]);
+ json_decref(array->table[idx]);
/* If we're removing the last element, nothing has to be moved */
- if(index < array->entries - 1)
- array_move(array, index, index + 1, array->entries - index - 1);
+ if(ind < array->entries - 1)
+ array_move(array, ind, ind + 1, array->entries - ind - 1);
+ if(idx < array->entries - 1)
+ array_move(array, idx, idx + 1, array->entries - idx - 1);
array->entries--;

View File

@ -3,5 +3,5 @@ include/jansson_config.h
lib/libjansson.a
lib/libjansson.so
lib/libjansson.so.4
lib/libjansson.so.4.7.0
lib/libjansson.so.4.8.0
libdata/pkgconfig/jansson.pc