41 lines
1.1 KiB
Diff
41 lines
1.1 KiB
Diff
|
|
From ff8ed0f094ddb48edad8169b711097f69fe8efea Mon Sep 17 00:00:00 2001
|
||
|
|
From: Eric Hawicz <erh+git@nimenees.com>
|
||
|
|
Date: Sun, 17 Nov 2024 22:11:24 -0500
|
||
|
|
Subject: [PATCH] Issue #881: don't allow json_tokener_new_ex() with a depth <
|
||
|
|
1
|
||
|
|
|
||
|
|
---
|
||
|
|
json_tokener.c | 3 +++
|
||
|
|
json_tokener.h | 1 +
|
||
|
|
2 files changed, 4 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/json_tokener.c b/json_tokener.c
|
||
|
|
index 773229e..1954bcd 100644
|
||
|
|
--- a/json_tokener.c
|
||
|
|
+++ b/json_tokener.c
|
||
|
|
@@ -154,6 +154,9 @@ struct json_tokener *json_tokener_new_ex(int depth)
|
||
|
|
{
|
||
|
|
struct json_tokener *tok;
|
||
|
|
|
||
|
|
+ if (depth < 1)
|
||
|
|
+ return NULL;
|
||
|
|
+
|
||
|
|
tok = (struct json_tokener *)calloc(1, sizeof(struct json_tokener));
|
||
|
|
if (!tok)
|
||
|
|
return NULL;
|
||
|
|
diff --git a/json_tokener.h b/json_tokener.h
|
||
|
|
index 54925e5..f53a761 100644
|
||
|
|
--- a/json_tokener.h
|
||
|
|
+++ b/json_tokener.h
|
||
|
|
@@ -206,6 +206,7 @@ JSON_EXPORT struct json_tokener *json_tokener_new(void);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Allocate a new json_tokener with a custom max nesting depth.
|
||
|
|
+ * The depth must be at least 1.
|
||
|
|
* @see JSON_TOKENER_DEFAULT_DEPTH
|
||
|
|
*/
|
||
|
|
JSON_EXPORT struct json_tokener *json_tokener_new_ex(int depth);
|
||
|
|
--
|
||
|
|
2.35.1.windows.2
|
||
|
|
|