mirror of https://github.com/acidanthera/audk.git
MdePkg DevicePathLib: Rollback former change.
Former patch still has some bugs, so rollback it and enhance the original code. Cc: Ruiyu NI <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
parent
49d8f534cc
commit
1420143f01
|
@ -103,35 +103,25 @@ IsDevicePathValid (
|
||||||
|
|
||||||
ASSERT (DevicePath != NULL);
|
ASSERT (DevicePath != NULL);
|
||||||
|
|
||||||
if (MaxSize == 0){
|
for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
|
||||||
MaxSize = MAX_UINTN;
|
|
||||||
}
|
|
||||||
|
|
||||||
Size = 0;
|
|
||||||
Count = 0;
|
|
||||||
|
|
||||||
while (MaxSize >= sizeof (EFI_DEVICE_PATH_PROTOCOL) &&
|
|
||||||
(MaxSize - sizeof (EFI_DEVICE_PATH_PROTOCOL) >= Size) &&
|
|
||||||
!IsDevicePathEnd (DevicePath)) {
|
|
||||||
NodeLength = DevicePathNodeLength (DevicePath);
|
NodeLength = DevicePathNodeLength (DevicePath);
|
||||||
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
|
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NodeLength > MAX_UINTN - Size) {
|
if (MaxSize > 0) {
|
||||||
return FALSE;
|
Size += NodeLength;
|
||||||
|
if (Size + END_DEVICE_PATH_LENGTH > MaxSize) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Size += NodeLength;
|
|
||||||
|
|
||||||
if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {
|
if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {
|
||||||
Count++;
|
Count++;
|
||||||
if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {
|
if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DevicePath = NextDevicePathNode (DevicePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue