sd-json: limit the number of env variables to something reasonable

Let's start with 1024, as that should be plenty for all sane use cases.
This commit is contained in:
Frantisek Sumsal
2026-04-30 09:46:46 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 1c534452e9
commit 7671b43cb8
2 changed files with 5 additions and 0 deletions
+3
View File
@@ -653,6 +653,9 @@ int json_dispatch_strv_environment(const char *name, sd_json_variant *variant, s
if (!sd_json_variant_is_array(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an array.", strna(name));
if (sd_json_variant_elements(variant) > ENVIRONMENT_ASSIGNMENTS_MAX)
return json_log(variant, flags, SYNTHETIC_ERRNO(E2BIG), "Too many environment variable assignments.");
sd_json_variant *i;
JSON_VARIANT_ARRAY_FOREACH(i, variant) {
const char *e;
+2
View File
@@ -9,6 +9,8 @@
#include "sd-forward.h"
#include "string-util.h" /* IWYU pragma: keep */
#define ENVIRONMENT_ASSIGNMENTS_MAX 1024U
#define JSON_VARIANT_REPLACE(v, q) \
do { \
typeof(v)* _v = &(v); \