From b08b045ca9ab46f335d2edc21eeea5340a1aea6b Mon Sep 17 00:00:00 2001 From: "Jim.Dailey@dell.com" Date: Sat, 6 Oct 2018 03:14:56 +0800 Subject: [PATCH] MdePkg-BaseLib: Fix PathCleanUpDirectories() issue with "\\..\\.." Replace multiple, consecutive "\" characters prior to other processing involving "\" characters. This fixes an issue where "\\..\\..", "//..//..", and similar input paths are not cleaned properly. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jim Dailey Reviewed-by: Ruiyu Ni Reviewed-by: Liming Gao --- MdePkg/Library/BaseLib/FilePaths.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MdePkg/Library/BaseLib/FilePaths.c b/MdePkg/Library/BaseLib/FilePaths.c index ce6b3720d5..92e4c350ff 100644 --- a/MdePkg/Library/BaseLib/FilePaths.c +++ b/MdePkg/Library/BaseLib/FilePaths.c @@ -86,6 +86,13 @@ PathCleanUpDirectories( } } + // + // Replace the "\\" with "\" + // + while ((TempString = StrStr (Path, L"\\\\")) != NULL) { + CopyMem (TempString, TempString + 1, StrSize (TempString + 1)); + } + // // Remove all the "\.". E.g.: fs0:\abc\.\def\. // @@ -109,13 +116,6 @@ PathCleanUpDirectories( } } - // - // Replace the "\\" with "\" - // - while ((TempString = StrStr (Path, L"\\\\")) != NULL) { - CopyMem (TempString, TempString + 1, StrSize (TempString + 1)); - } - return Path; }