From 6c98228726c26936c81b498d2837c7af7731be3c Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Mon, 20 Dec 2021 22:45:24 +0100 Subject: [PATCH] Fixed scan depth check --- src/raspberrypi/rascsi_image.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/raspberrypi/rascsi_image.cpp b/src/raspberrypi/rascsi_image.cpp index 9cbb79f8..82ff84ce 100644 --- a/src/raspberrypi/rascsi_image.cpp +++ b/src/raspberrypi/rascsi_image.cpp @@ -251,6 +251,10 @@ bool RascsiImage::RenameImage(int fd, const PbCommand& command) return ReturnStatus(fd, false, "Can't rename image file: Missing source filename"); } + if (!CheckDepth(from)) { + return ReturnStatus(fd, false, ("Invalid folder hierarchy depth '" + from + "'").c_str()); + } + from = default_image_folder + "/" + from; if (!IsValidSrcFilename(from)) { return ReturnStatus(fd, false, "Can't rename image file: '" + from + "': Invalid name or type"); @@ -261,10 +265,6 @@ bool RascsiImage::RenameImage(int fd, const PbCommand& command) return ReturnStatus(fd, false, "Can't rename image file '" + from + "': Missing destination filename"); } - if (!CheckDepth(from)) { - return ReturnStatus(fd, false, ("Invalid folder hierarchy depth '" + from + "'").c_str()); - } - if (!CheckDepth(to)) { return ReturnStatus(fd, false, ("Invalid folder hierarchy depth '" + to + "'").c_str()); } @@ -294,6 +294,10 @@ bool RascsiImage::CopyImage(int fd, const PbCommand& command) return ReturnStatus(fd, false, "Can't copy image file: Missing source filename"); } + if (!CheckDepth(from)) { + return ReturnStatus(fd, false, ("Invalid folder hierarchy depth '" + from + "'").c_str()); + } + from = default_image_folder + "/" + from; if (!IsValidSrcFilename(from)) { return ReturnStatus(fd, false, "Can't copy image file: '" + from + "': Invalid name or type"); @@ -304,10 +308,6 @@ bool RascsiImage::CopyImage(int fd, const PbCommand& command) return ReturnStatus(fd, false, "Can't copy image file '" + from + "': Missing destination filename"); } - if (!CheckDepth(from)) { - return ReturnStatus(fd, false, ("Invalid folder hierarchy depth '" + from + "'").c_str()); - } - if (!CheckDepth(to)) { return ReturnStatus(fd, false, ("Invalid folder hierarchy depth '" + to + "'").c_str()); }