summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authorEric Dong <eric.dong@intel.com>2016-10-27 14:16:53 +0800
committerStar Zeng <star.zeng@intel.com>2016-11-09 17:49:16 +0800
commitfb9405f9583a6ecf2048cdcc2e8d5621a3e68c75 (patch)
tree635ddf0455b7e0b41d29040a50bf9a1979c84bef /MdePkg
parentc0cba3d5ddec83e2bf09deb01a25140a71f8b7e6 (diff)
downloadedk2-platforms-fb9405f9583a6ecf2048cdcc2e8d5621a3e68c75.tar.xz
MdePkg UefiDevicePathLib: Rollback former change.
Former patch still has some bugs, so rollback it and enhance the original code. Cc: Ruiyu NI <ruiyu.ni@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.dong@intel.com>
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
index 82419a4e1b..024dcc271d 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
@@ -61,35 +61,25 @@ IsDevicePathValid (
ASSERT (DevicePath != NULL);
- if (MaxSize == 0){
- MaxSize = MAX_UINTN;
- }
-
- Size = 0;
- Count = 0;
-
- while (MaxSize >= sizeof (EFI_DEVICE_PATH_PROTOCOL) &&
- (MaxSize - sizeof (EFI_DEVICE_PATH_PROTOCOL) >= Size) &&
- !IsDevicePathEnd (DevicePath)) {
+ for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
NodeLength = DevicePathNodeLength (DevicePath);
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
return FALSE;
}
- if (NodeLength > MAX_UINTN - Size) {
- return FALSE;
+ if (MaxSize > 0) {
+ Size += NodeLength;
+ if (Size + END_DEVICE_PATH_LENGTH > MaxSize) {
+ return FALSE;
+ }
}
- Size += NodeLength;
-
if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {
Count++;
if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {
return FALSE;
}
}
-
- DevicePath = NextDevicePathNode (DevicePath);
}
//