aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-17 23:29:42 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-17 23:30:22 +0200
commitf9e157293c8bbfe56d29218cbe3b2c6fdc1ea2ba (patch)
tree1721e73aac56b2e4af07c4c6ec0acfbac49ac0af
parent42d1ff064f8d56ec7ec9e0b50d1c8eed8485f538 (diff)
downloadjson-rpc-shell-f9e157293c8bbfe56d29218cbe3b2c6fdc1ea2ba.tar.gz
json-rpc-shell-f9e157293c8bbfe56d29218cbe3b2c6fdc1ea2ba.tar.xz
json-rpc-shell-f9e157293c8bbfe56d29218cbe3b2c6fdc1ea2ba.zip
json-rpc-test-server: only return regular files
They can be symlinked.
-rw-r--r--json-rpc-test-server.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/json-rpc-test-server.c b/json-rpc-test-server.c
index 07a2dd5..801fb88 100644
--- a/json-rpc-test-server.c
+++ b/json-rpc-test-server.c
@@ -1925,8 +1925,13 @@ request_handler_static_try_handle
char *path = xstrdup_printf ("%s%s", root, suffix);
print_debug ("trying to statically serve %s", path);
- // TODO: check that this is a regular file
FILE *fp = fopen (path, "rb");
+ struct stat st = {};
+ if (fp && !fstat (fileno (fp), &st) && !S_ISREG (st.st_mode))
+ {
+ fclose (fp);
+ fp = NULL;
+ }
if (!fp)
{
struct str response = str_make ();