From cdbabe0e58a9ede818db0c73f0dc497e66b77bf0 Mon Sep 17 00:00:00 2001 From: Patedam Date: Tue, 3 Mar 2026 13:18:29 -0500 Subject: [PATCH] Fixing gz snprintf not matching sizes --- Provider/main/http_server.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Provider/main/http_server.cpp b/Provider/main/http_server.cpp index f2b756a..8602cfb 100644 --- a/Provider/main/http_server.cpp +++ b/Provider/main/http_server.cpp @@ -14,6 +14,8 @@ internal const char *TAG = "HTTP_SERVER"; +constexpr uint8 kGZ_Extension_Length = sizeof(".gz") - 1; + #define FILE_PATH_MAX (ESP_VFS_PATH_MAX + 128) #define SCRATCH_BUFSIZE 4096 @@ -58,7 +60,7 @@ internal esp_err_t static_file_handler(httpd_req_t *req) { struct stat file_stat; if (stat(filepath, &file_stat) == -1) { // Try gzipped first, then fallback to index.html - char filepath_gz[FILE_PATH_MAX + 16]; + char filepath_gz[FILE_PATH_MAX + kGZ_Extension_Length]; snprintf(filepath_gz, sizeof(filepath_gz), "%s.gz", filepath); if (stat(filepath_gz, &file_stat) == 0) { strlcpy(filepath, filepath_gz, sizeof(filepath));