From 07a49a7a2d7707e6257a0434c8b102c2056eb80e Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Tue, 23 Jun 2026 13:38:16 -0300 Subject: [PATCH] fix for new path_is_sane treatment of nul --- mongoose.c | 4 ++-- src/http.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mongoose.c b/mongoose.c index d720c0ab..7bd165e1 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4051,11 +4051,11 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm, path_size - n, 0); } path[path_size - 1] = '\0'; // Double-check - if (!mg_path_is_sane(mg_str_n(path, path_size))) { + n = strlen(path); + if (!mg_path_is_sane(mg_str_n(path, n))) { mg_http_reply(c, 400, "", "Invalid path"); return -1; } - n = strlen(path); while (n > 1 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes flags = mg_strcmp(hm->uri, mg_str("/")) == 0 ? MG_FS_DIR : fs->st(path, NULL, NULL); diff --git a/src/http.c b/src/http.c index 50aaead7..4ade7717 100644 --- a/src/http.c +++ b/src/http.c @@ -803,11 +803,11 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm, path_size - n, 0); } path[path_size - 1] = '\0'; // Double-check - if (!mg_path_is_sane(mg_str_n(path, path_size))) { + n = strlen(path); + if (!mg_path_is_sane(mg_str_n(path, n))) { mg_http_reply(c, 400, "", "Invalid path"); return -1; } - n = strlen(path); while (n > 1 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes flags = mg_strcmp(hm->uri, mg_str("/")) == 0 ? MG_FS_DIR : fs->st(path, NULL, NULL);