mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-19 19:40:56 +00:00
fix for new path_is_sane treatment of nul
This commit is contained in:
1 parent
98dc50b3cd
commit
07a49a7a2d
2 files changed
+4
-4
No files matched your search
+2
-2
@@ -4051,11 +4051,11 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm,
|
|||||||
path_size - n, 0);
|
path_size - n, 0);
|
||||||
}
|
}
|
||||||
path[path_size - 1] = '\0'; // Double-check
|
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");
|
mg_http_reply(c, 400, "", "Invalid path");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
n = strlen(path);
|
|
||||||
while (n > 1 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes
|
while (n > 1 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes
|
||||||
flags = mg_strcmp(hm->uri, mg_str("/")) == 0 ? MG_FS_DIR
|
flags = mg_strcmp(hm->uri, mg_str("/")) == 0 ? MG_FS_DIR
|
||||||
: fs->st(path, NULL, NULL);
|
: fs->st(path, NULL, NULL);
|
||||||
|
|||||||
+2
-2
@@ -803,11 +803,11 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm,
|
|||||||
path_size - n, 0);
|
path_size - n, 0);
|
||||||
}
|
}
|
||||||
path[path_size - 1] = '\0'; // Double-check
|
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");
|
mg_http_reply(c, 400, "", "Invalid path");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
n = strlen(path);
|
|
||||||
while (n > 1 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes
|
while (n > 1 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes
|
||||||
flags = mg_strcmp(hm->uri, mg_str("/")) == 0 ? MG_FS_DIR
|
flags = mg_strcmp(hm->uri, mg_str("/")) == 0 ? MG_FS_DIR
|
||||||
: fs->st(path, NULL, NULL);
|
: fs->st(path, NULL, NULL);
|
||||||
|
|||||||
Reference in new issue
Block a user