Discussion:
[edk2] [PATCH 2/2] MdePkg/Library/UefiFileHandleLib: Do the validation for DirHandle before get file information.
Qiu Shumin
1970-01-01 00:00:00 UTC
Permalink
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <***@intel.com>
---
MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
index 7687ca3..25bb8fb 100644
--- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
+++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
@@ -407,7 +407,14 @@ FileHandleIsDirectory (
if (DirHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
-
+
+ //
+ // check whether the DirHandle is valid
+ //
+ if (DirHandle->Revision != EFI_FILE_PROTOCOL_LATEST_REVISION) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// get the file information for DirHandle
//
--
1.9.5.msysgit.1



------------------------------------------------------------------------------
Carsey, Jaben
2015-06-10 17:29:26 UTC
Permalink
Why do we need to check against the latest revision? Can't we use the version of the protocol that we need the feature from?

I like the idea of the check.

-Jaben
-----Original Message-----
From: Qiu, Shumin
Sent: Wednesday, June 10, 2015 1:22 AM
Cc: Gao, Liming; Carsey, Jaben
Subject: [PATCH 2/2] MdePkg/Library/UefiFileHandleLib: Do the validation
for DirHandle before get file information.
Contributed-under: TianoCore Contribution Agreement 1.0
---
MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
index 7687ca3..25bb8fb 100644
--- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
+++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
@@ -407,7 +407,14 @@ FileHandleIsDirectory (
if (DirHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
-
+
+ //
+ // check whether the DirHandle is valid
+ //
+ if (DirHandle->Revision != EFI_FILE_PROTOCOL_LATEST_REVISION) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// get the file information for DirHandle
//
--
1.9.5.msysgit.1
------------------------------------------------------------------------------
Ni, Ruiyu
2015-06-11 01:30:33 UTC
Permalink
Depending on whether the low-layer produces BlockIo2 protocol, the Fat driver doesn't always produce REVISION_2 for FileHandle/DirHandle.
So either we can check both the REVISION_1 and REVISION_2, or we can remove this check because the rubbish data can happen to be REVISION_1 or REVISION_2 but it doesn't mean the rubbish data is valid.

Thanks,
Ray
-----Original Message-----
Sent: Thursday, June 11, 2015 1:29 AM
Subject: Re: [edk2] [PATCH 2/2] MdePkg/Library/UefiFileHandleLib: Do the
validation for DirHandle before get file information.
Why do we need to check against the latest revision? Can't we use the
version of the protocol that we need the feature from?
I like the idea of the check.
-Jaben
-----Original Message-----
From: Qiu, Shumin
Sent: Wednesday, June 10, 2015 1:22 AM
Cc: Gao, Liming; Carsey, Jaben
Subject: [PATCH 2/2] MdePkg/Library/UefiFileHandleLib: Do the validation
for DirHandle before get file information.
Contributed-under: TianoCore Contribution Agreement 1.0
---
MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
index 7687ca3..25bb8fb 100644
--- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
+++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
@@ -407,7 +407,14 @@ FileHandleIsDirectory (
if (DirHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
-
+
+ //
+ // check whether the DirHandle is valid
+ //
+ if (DirHandle->Revision != EFI_FILE_PROTOCOL_LATEST_REVISION) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// get the file information for DirHandle
//
--
1.9.5.msysgit.1
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Loading...