From: Wilfried Goesgens Date: Mon, 25 Feb 2013 19:48:08 +0000 (+0100) Subject: File-Handling: sanitize filenames. X-Git-Tag: v8.20~86 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=21ab241ce134dfd2dd1520249e569d4b71c6e6e2 File-Handling: sanitize filenames. --- 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,