public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] Add sanity check for FilePath device path
@ 2019-01-29  5:09 Jian J Wang
  2019-01-29  5:09 ` [PATCH 1/2] MdePkg/UefiDevicePathLib: " Jian J Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jian J Wang @ 2019-01-29  5:09 UTC (permalink / raw)
  To: edk2-devel

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497

Jian J Wang (2):
  MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path
  MdePkg/UefiDevicePathLibDevicePathProtocol: Add sanity check for
    FilePath device path

 MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c    | 8 ++++++++
 .../UefiDevicePathLib.c                                   | 8 ++++++++
 2 files changed, 16 insertions(+)

-- 
2.19.0.windows.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path
  2019-01-29  5:09 [PATCH 0/2] Add sanity check for FilePath device path Jian J Wang
@ 2019-01-29  5:09 ` Jian J Wang
  2019-01-29  5:09 ` [PATCH 2/2] MdePkg/UefiDevicePathLibDevicePathProtocol: " Jian J Wang
  2019-01-29  5:28 ` [PATCH 0/2] " Wang, Jian J
  2 siblings, 0 replies; 4+ messages in thread
From: Jian J Wang @ 2019-01-29  5:09 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Ray Ni, Michael D Kinney

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497

Current implementation of IsDevicePathValid() is not enough for type
of MEDIA_FILEPATH_DP, which has NULL-terminated string in the device
path. This patch add a simple NULL character check at Length position.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
---
 MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
index 665e5a4adc..6d87744510 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
@@ -96,6 +96,14 @@ IsDevicePathValid (
         return FALSE;
       }
     }
+
+    //
+    // FilePath must be a NULL-terminated string.
+    //
+    if (DevicePathType (DevicePath) == MEDIA_FILEPATH_DP &&
+        *(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {
+      return FALSE;
+    }
   }
 
   //
-- 
2.19.0.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] MdePkg/UefiDevicePathLibDevicePathProtocol: Add sanity check for FilePath device path
  2019-01-29  5:09 [PATCH 0/2] Add sanity check for FilePath device path Jian J Wang
  2019-01-29  5:09 ` [PATCH 1/2] MdePkg/UefiDevicePathLib: " Jian J Wang
@ 2019-01-29  5:09 ` Jian J Wang
  2019-01-29  5:28 ` [PATCH 0/2] " Wang, Jian J
  2 siblings, 0 replies; 4+ messages in thread
From: Jian J Wang @ 2019-01-29  5:09 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Ray Ni, Michael D Kinney

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497

Current implementation of IsDevicePathValid() is not enough for type
of MEDIA_FILEPATH_DP, which has NULL-terminated string in the device
path. This patch add a simple NULL character check at Length position.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
---
 .../UefiDevicePathLib.c                                   | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
index 9a0ee42fd1..5dc413de44 100644
--- a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
+++ b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
@@ -138,6 +138,14 @@ IsDevicePathValid (
         return FALSE;
       }
     }
+
+    //
+    // FilePath must be a NULL-terminated string.
+    //
+    if (DevicePathType (DevicePath) == MEDIA_FILEPATH_DP &&
+        *(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {
+      return FALSE;
+    }
   }
 
   //
-- 
2.19.0.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Add sanity check for FilePath device path
  2019-01-29  5:09 [PATCH 0/2] Add sanity check for FilePath device path Jian J Wang
  2019-01-29  5:09 ` [PATCH 1/2] MdePkg/UefiDevicePathLib: " Jian J Wang
  2019-01-29  5:09 ` [PATCH 2/2] MdePkg/UefiDevicePathLibDevicePathProtocol: " Jian J Wang
@ 2019-01-29  5:28 ` Wang, Jian J
  2 siblings, 0 replies; 4+ messages in thread
From: Wang, Jian J @ 2019-01-29  5:28 UTC (permalink / raw)
  To: Wang, Jian J, edk2-devel@lists.01.org

Miss the test info:
- Boot shell
- Boot to Fedora 26 (Qemu/x64)
- Boot to Ubuntu 18.04 (Qemu/x64)
- Boot to Windows 10 (Qemu/x64)
- Boot to Windows 7 (Qemu/x64)

Regards,
Jian


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jian J
> Wang
> Sent: Tuesday, January 29, 2019 1:10 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH 0/2] Add sanity check for FilePath device path
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497
> 
> Jian J Wang (2):
>   MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path
>   MdePkg/UefiDevicePathLibDevicePathProtocol: Add sanity check for
>     FilePath device path
> 
>  MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c    | 8 ++++++++
>  .../UefiDevicePathLib.c                                   | 8 ++++++++
>  2 files changed, 16 insertions(+)
> 
> --
> 2.19.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-29  5:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-29  5:09 [PATCH 0/2] Add sanity check for FilePath device path Jian J Wang
2019-01-29  5:09 ` [PATCH 1/2] MdePkg/UefiDevicePathLib: " Jian J Wang
2019-01-29  5:09 ` [PATCH 2/2] MdePkg/UefiDevicePathLibDevicePathProtocol: " Jian J Wang
2019-01-29  5:28 ` [PATCH 0/2] " Wang, Jian J

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox