Skip to content

Commit

Permalink
ulpatch: Fix segvfault
Browse files Browse the repository at this point in the history
    $ ulpatch -p $(pidof hello) --patch patch-add-vars.ulp.no-build-id --lv=dbg -v
    11:20:59 [DEBUG][ehdr.c ehdr_magic_ok:20] Wrong ELF magic
    11:20:59 [ERROR][patch.c setup_load_info:370] Not found Build ID or .note.gnu.build-id section.
    Add gcc argument '-Wl,--build-id=sha1'
    or Add linker(ld) argument '--build-id=sha1'
    11:20:59 [DEBUG][ulpatch.c check_patch_file:147] Load patch-add-vars.ulp.no-build-id failed
    munmap_chunk(): invalid pointer
    Aborted (core dumped)

Signed-off-by: Rong Tao <[email protected]>
  • Loading branch information
Rtoax committed Mar 8, 2024
1 parent f946fde commit 489bc4c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/patch/patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void release_load_info(struct load_info *info)
free(info->str_build_id);
info->str_build_id = NULL;
}

if (info->ulp_name) {
free(info->ulp_name);
info->ulp_name = NULL;
Expand Down Expand Up @@ -890,6 +891,7 @@ int init_patch(struct task_struct *task, const char *obj_file)

struct load_info info = {
.target_task = task,
.str_build_id = NULL,
};

if (!(task->fto_flag & FTO_PROC)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ulpatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static int parse_config(int argc, char *argv[])
int check_patch_file(const char *file)
{
int err = 0;
struct load_info info;
struct load_info info = {0};

if (!file)
return -EEXIST;
Expand Down

0 comments on commit 489bc4c

Please sign in to comment.