From 21ab241ce134dfd2dd1520249e569d4b71c6e6e2 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Mon, 25 Feb 2013 20:48:08 +0100 Subject: [PATCH] File-Handling: sanitize filenames. --- citadel/file_ops.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/citadel/file_ops.c b/citadel/file_ops.c index b52915e70..5547c005e 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -203,6 +203,12 @@ void cmd_open(char *cmdbuf) ERROR + FILE_NOT_FOUND); return; } + if (strstr(filename, "../") != NULL) + { + cprintf("%d syntax error.\n", + ERROR + ILLEGAL_VALUE); + return; + } if (CC->download_fp != NULL) { cprintf("%d You already have a download file open.\n", @@ -284,6 +290,13 @@ void cmd_oimg(char *cmdbuf) filename[a] = '_'; } } + if (strstr(filename, "../") != NULL) + { + cprintf("%d syntax error.\n", + ERROR + ILLEGAL_VALUE); + return; + } + snprintf(pathname, sizeof pathname, "%s/%s", ctdl_image_dir, -- 2.30.2