Skip to content

Commit

Permalink
sk-inet: Duplicate and free ping_group_range buffer
Browse files Browse the repository at this point in the history
Fixes the `stack-use-after-scope` error from the address sanitizer
since the local variable `buffer`, goes out of scope.

Signed-off-by: समीर सिंह Sameer Singh <lumarzeli30@gmail.com>
  • Loading branch information
ss141309 committed Jan 11, 2025
1 parent 6dc6ed3 commit 64f18bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion criu/sk-inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,10 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
}

buffer[strlen(buffer)] = '\0';
ie.ping_grp_range = buffer;

ie.ping_grp_range = xstrdup(buffer);
if (!ie.ping_grp_range)
goto err;
}

pr_info("Dumping inet socket at %d\n", p->fd);
Expand Down Expand Up @@ -645,6 +648,7 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
xfree(ie.src_addr);
xfree(ie.dst_addr);
xfree(ie.ifname);
xfree(ie.ping_grp_range);
return err;
}

Expand Down

0 comments on commit 64f18bc

Please sign in to comment.