diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2018-04-16 07:59:06 +0200 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2018-04-23 21:34:28 +0200 |
commit | 07836345ba6da5cdad2bbdc43923604d256645f3 (patch) | |
tree | a5f73ca42291b1f3dea8aca4443a44c2ccf5bb9f /lib | |
parent | 211314c107d759c6adeb9b5dd8c81b284c4a03be (diff) | |
download | u-boot-07836345ba6da5cdad2bbdc43923604d256645f3.tar.gz |
efi_loader: fix AppendDevicePath
The logic of the AppendDevicePath service of the
EFI_DEVICE_PATH_UTILITIES_PROTOCOL is incorrectly implemented:
* if both paths are NULL an end node has to be returned
* if both paths are not NULL the end node of the second device path has to
be kept
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/efi_loader/efi_device_path.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 0cd0b459e3..9b4d9ae0ab 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -263,7 +263,10 @@ struct efi_device_path *efi_dp_append(const struct efi_device_path *dp1, { struct efi_device_path *ret; - if (!dp1) { + if (!dp1 && !dp2) { + /* return an end node */ + ret = efi_dp_dup(&END); + } else if (!dp1) { ret = efi_dp_dup(dp2); } else if (!dp2) { ret = efi_dp_dup(dp1); @@ -275,8 +278,8 @@ struct efi_device_path *efi_dp_append(const struct efi_device_path *dp1, if (!p) return NULL; memcpy(p, dp1, sz1); - memcpy(p + sz1, dp2, sz2); - memcpy(p + sz1 + sz2, &END, sizeof(END)); + /* the end node of the second device path has to be retained */ + memcpy(p + sz1, dp2, sz2 + sizeof(END)); ret = p; } |