[PATCH cgi-io] main: allow underscore character in filename/mimetype
ptpt52 at gmail.com
ptpt52 at gmail.com
Thu Aug 11 10:04:32 PDT 2022
From: Chen Minqiang <ptpt52 at gmail.com>
This add underscore character to valid char list in filename or in
mimetype. It is not usual but should theoretically be valid.
Signed-off-by: Chen Minqiang <ptpt52 at gmail.com>
---
main.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/main.c b/main.c
index 8ca4c04..9e715de 100644
--- a/main.c
+++ b/main.c
@@ -547,11 +547,11 @@ main_download(int argc, char **argv)
return failure(403, 0, "Requested path is not a regular file or block device");
for (p = fields[5]; p && *p; p++)
- if (!isalnum(*p) && !strchr(" ()<>@,;:[]?.=%-", *p))
+ if (!isalnum(*p) && !strchr(" ()<>@,;:[]?.=%-_", *p))
return failure(400, 0, "Invalid characters in filename");
for (p = fields[7]; p && *p; p++)
- if (!isalnum(*p) && !strchr(" .;=/-", *p))
+ if (!isalnum(*p) && !strchr(" .;=/-_", *p))
return failure(400, 0, "Invalid characters in mimetype");
rfd = open(fields[3], O_RDONLY);
@@ -745,11 +745,11 @@ main_exec(int argc, char **argv)
return failure(403, 0, "Exec permission denied");
for (p = fields[5]; p && *p; p++)
- if (!isalnum(*p) && !strchr(" ()<>@,;:[]?.=%-", *p))
+ if (!isalnum(*p) && !strchr(" ()<>@,;:[]?.=%-_", *p))
return failure(400, 0, "Invalid characters in filename");
for (p = fields[7]; p && *p; p++)
- if (!isalnum(*p) && !strchr(" .;=/-", *p))
+ if (!isalnum(*p) && !strchr(" .;=/-_", *p))
return failure(400, 0, "Invalid characters in mimetype");
args = fields[3] ? parse_command(fields[3]) : NULL;
--
2.17.1
More information about the openwrt-devel
mailing list