From 14b8bb2bb52f71580b79316b38775caed0c07202 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 30 Apr 2026 09:33:48 +0800 Subject: [PATCH] Temps: validates temp color thresholds as integers in JSON parsing Co-authored-by: Copilot --- src/common/impl/temps.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common/impl/temps.c b/src/common/impl/temps.c index 7bb2a6665..ae51e65b3 100644 --- a/src/common/impl/temps.c +++ b/src/common/impl/temps.c @@ -123,7 +123,12 @@ bool ffTempsParseJsonObject(yyjson_val* key, yyjson_val* value, bool* useTemp, F yyjson_val* greenVal = yyjson_obj_get(value, "green"); if (greenVal) { - int num = yyjson_get_int(greenVal); + if (!yyjson_is_int(greenVal)) { + fputs("Error: usage: temp.green must be an integer between 0 and 100\n", stderr); + exit(480); + } + + int num = unsafe_yyjson_get_int(greenVal); if (num < 0 || num > 100) { fputs("Error: usage: temp.green must be between 0 and 100\n", stderr); exit(480); @@ -133,7 +138,12 @@ bool ffTempsParseJsonObject(yyjson_val* key, yyjson_val* value, bool* useTemp, F yyjson_val* yellowVal = yyjson_obj_get(value, "yellow"); if (yellowVal) { - int num = yyjson_get_int(yellowVal); + if (!yyjson_is_int(yellowVal)) { + fputs("Error: usage: temp.yellow must be an integer between 0 and 100\n", stderr); + exit(480); + } + + int num = unsafe_yyjson_get_int(yellowVal); if (num < 0 || num > 100) { fputs("Error: usage: temp.yellow must be between 0 and 100\n", stderr); exit(480);