return chopped;
}
+static EFI_DEVICE_PATH *path_dup(const EFI_DEVICE_PATH *dp) {
+ assert(dp);
+
+ const EFI_DEVICE_PATH *node = dp;
+ size_t size = 0;
+ while (!IsDevicePathEnd(node)) {
+ size += DevicePathNodeLength(node);
+ node = NextDevicePathNode(node);
+ }
+ size += DevicePathNodeLength(node);
+
+ EFI_DEVICE_PATH *dup = xmalloc(size);
+ memcpy(dup, dp, size);
+ return dup;
+}
+
static BOOLEAN verify_gpt(union GptHeaderBuffer *gpt_header_buffer, EFI_LBA lba_expected) {
EFI_PARTITION_TABLE_HEADER *h;
UINT32 crc32, crc32_saved;
}
/* Patch in the data we found */
- EFI_DEVICE_PATH *xboot_path = ASSERT_SE_PTR(DuplicateDevicePath(partition_path));
+ EFI_DEVICE_PATH *xboot_path = path_dup(partition_path);
memcpy((UINT8 *) xboot_path + ((UINT8 *) part_node - (UINT8 *) partition_path), &hd, sizeof(hd));
*ret_device_path = xboot_path;
return EFI_SUCCESS;