From 04e8a518ea5a3026a02b15040d0b85799bf30d16 Mon Sep 17 00:00:00 2001 From: Erik Olof Gunnar Andersson Date: Sat, 28 Sep 2024 05:43:41 +0200 Subject: [PATCH] Protect against negative frequency values (#326) --- main/http_server/http_server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/http_server/http_server.c b/main/http_server/http_server.c index 4dc83ac23..7c589608b 100644 --- a/main/http_server/http_server.c +++ b/main/http_server/http_server.c @@ -290,10 +290,10 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req) if ((item = cJSON_GetObjectItem(root, "hostname")) != NULL) { nvs_config_set_string(NVS_CONFIG_HOSTNAME, item->valuestring); } - if ((item = cJSON_GetObjectItem(root, "coreVoltage")) != NULL) { + if ((item = cJSON_GetObjectItem(root, "coreVoltage")) != NULL && item->valueint > 0) { nvs_config_set_u16(NVS_CONFIG_ASIC_VOLTAGE, item->valueint); } - if ((item = cJSON_GetObjectItem(root, "frequency")) != NULL) { + if ((item = cJSON_GetObjectItem(root, "frequency")) != NULL && item->valueint > 0) { nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, item->valueint); } if ((item = cJSON_GetObjectItem(root, "flipscreen")) != NULL) {