From: Hao Wu <hao.a.wu@intel.com>
To: edk2-devel@lists.01.org
Cc: Hao Wu <hao.a.wu@intel.com>, Ruiyu Ni <ruiyu.ni@intel.com>,
Liming Gao <liming.gao@intel.com>
Subject: [PATCH] MdePkg BaseLib: API PathRemoveLastItem not handle root paths properly
Date: Thu, 17 Nov 2016 11:39:25 +0800 [thread overview]
Message-ID: <1479353965-21600-1-git-send-email-hao.a.wu@intel.com> (raw)
https://bugzilla.tianocore.org/show_bug.cgi?id=239
When the input path for API PathRemoveLastItem() is a root path like
'fs0:\', the API will return TRUE (indicating a directory or file was
removed from the path) and modifies the path to 'fs0:'. In fact, there's
no directory or file removed in the above case.
This commit adds additional check to resolve this issue and modifies the
API's description to make it more straightforward.
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdePkg/Include/Library/BaseLib.h | 3 +--
MdePkg/Library/BaseLib/FilePaths.c | 8 ++++----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index 6268e6f..b69c703 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -1747,8 +1747,7 @@ BcdToDecimal8 (
//
/**
- Removes the last directory or file entry in a path by changing the last
- L'\' to a CHAR_NULL.
+ Removes the last directory or file entry in a path.
@param[in, out] Path The pointer to the path to modify.
diff --git a/MdePkg/Library/BaseLib/FilePaths.c b/MdePkg/Library/BaseLib/FilePaths.c
index 183b323..4aa8554 100644
--- a/MdePkg/Library/BaseLib/FilePaths.c
+++ b/MdePkg/Library/BaseLib/FilePaths.c
@@ -14,9 +14,8 @@
#include <Library/BaseLib.h>
/**
- Removes the last directory or file entry in a path by changing the last
- L'\' to a CHAR_NULL. For a path which is like L"fs0:startup.nsh",
- it's converted to L"fs0:".
+ Removes the last directory or file entry in a path. For a path which is
+ like L"fs0:startup.nsh", it's converted to L"fs0:".
@param[in,out] Path A pointer to the path to modify.
@@ -38,7 +37,8 @@ PathRemoveLastItem(
; Walker != NULL && *Walker != CHAR_NULL
; Walker++
){
- if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != CHAR_NULL) {
+ if ((*Walker == L'\\' || *Walker == L':') &&
+ (*(Walker + 1) != L'\\' && *(Walker + 1) != CHAR_NULL)) {
LastSlash = Walker+1;
}
}
--
1.9.5.msysgit.0
reply other threads:[~2016-11-17 3:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1479353965-21600-1-git-send-email-hao.a.wu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox