42 lines
1.4 KiB
Diff
42 lines
1.4 KiB
Diff
From ed7492d5090a249c50c49501e8865c05de481c94 Mon Sep 17 00:00:00 2001
|
|
From: renoseven <dev@renoseven.net>
|
|
Date: Fri, 22 Dec 2023 15:22:03 +0800
|
|
Subject: [PATCH 10/15] daemon: fix check build id logic
|
|
|
|
Signed-off-by: renoseven <dev@renoseven.net>
|
|
---
|
|
upatch/upatch-tool/upatch-elf.c | 17 ++++++++++++-----
|
|
1 file changed, 12 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/upatch/upatch-tool/upatch-elf.c b/upatch/upatch-tool/upatch-elf.c
|
|
index def536c..730c3bd 100644
|
|
--- a/upatch/upatch-tool/upatch-elf.c
|
|
+++ b/upatch/upatch-tool/upatch-elf.c
|
|
@@ -201,11 +201,18 @@ out:
|
|
|
|
bool check_build_id(struct elf_info *uelf, struct elf_info *relf)
|
|
{
|
|
- return uelf->shdrs[uelf->num_build_id].sh_size ==
|
|
- relf->shdrs[relf->num_build_id].sh_size &&
|
|
- !memcmp(uelf->hdr + uelf->shdrs[uelf->num_build_id].sh_offset,
|
|
- relf->hdr + relf->shdrs[relf->num_build_id].sh_offset,
|
|
- uelf->shdrs[uelf->num_build_id].sh_size);
|
|
+ if (uelf->shdrs[uelf->num_build_id].sh_size != relf->shdrs[relf->num_build_id].sh_size) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ void* uelf_build_id = (void *)uelf->hdr + uelf->shdrs[uelf->num_build_id].sh_offset;
|
|
+ void* relf_build_id = (void *)relf->hdr + relf->shdrs[relf->num_build_id].sh_offset;
|
|
+ size_t build_id_len = uelf->shdrs[uelf->num_build_id].sh_size;
|
|
+
|
|
+ if (memcmp(uelf_build_id, relf_build_id, build_id_len) != 0) {
|
|
+ return false;
|
|
+ }
|
|
+ return true;
|
|
}
|
|
|
|
void binary_close(struct running_elf *relf)
|
|
--
|
|
2.33.0
|
|
|