From f9e157293c8bbfe56d29218cbe3b2c6fdc1ea2ba Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sat, 17 Oct 2020 23:29:42 +0200 Subject: json-rpc-test-server: only return regular files They can be symlinked. --- json-rpc-test-server.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 (); -- cgit v1.2.3-70-g09d2