\r
}\r
\r
-/**\r
- Validate the device path instance. \r
-\r
- Only base on the length filed in the device path node to validate the device path. \r
-\r
- @param DevicePath A pointer to a device path data structure.\r
- @param MaxSize Max valid device path size. If big than this size, \r
- return error.\r
- \r
- @retval TRUE An valid device path.\r
- @retval FALSE An invalid device path.\r
-\r
-**/\r
-BOOLEAN\r
-IsValidDevicePath (\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
- IN UINTN MaxSize\r
- )\r
-{\r
- UINTN Size;\r
- UINTN NodeSize;\r
-\r
- if (DevicePath == NULL) {\r
- return TRUE;\r
- }\r
-\r
- Size = 0;\r
-\r
- while (!IsDevicePathEnd (DevicePath)) {\r
- NodeSize = DevicePathNodeLength (DevicePath);\r
- if (NodeSize < END_DEVICE_PATH_LENGTH) {\r
- return FALSE;\r
- }\r
-\r
- Size += NodeSize;\r
- if (Size > MaxSize) {\r
- return FALSE;\r
- }\r
-\r
- DevicePath = NextDevicePathNode (DevicePath);\r
- }\r
-\r
- Size += DevicePathNodeLength (DevicePath);\r
- if (Size > MaxSize) {\r
- return FALSE;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
/**\r
\r
Validate input console variable data. \r
&gEfiGlobalVariableGuid,\r
&VariableSize\r
);\r
- if (!IsValidDevicePath (DevicePath, VariableSize)) { \r
+ if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) { \r
Status = gRT->SetVariable (\r
VariableName,\r
&gEfiGlobalVariableGuid,\r