Skip to content

Commit

Permalink
cgroups: ensure all memory is zeroed
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 8, 2021
1 parent 9dee31e commit 8f9cd8d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lxc/cgroups/cgroup2_devices.c
Expand Up @@ -52,8 +52,9 @@ static int bpf_program_add_instructions(struct bpf_program *prog,
new_insn = realloc(prog->instructions, sizeof(struct bpf_insn) * (count + prog->n_instructions));
if (!new_insn)
return log_error_errno(-1, ENOMEM, "Failed to reallocate bpf cgroup program");

prog->instructions = new_insn;
memset(prog->instructions + prog->n_instructions, 0,
sizeof(struct bpf_insn) * count);
memcpy(prog->instructions + prog->n_instructions, instructions,
sizeof(struct bpf_insn) * count);
prog->n_instructions += count;
Expand Down

0 comments on commit 8f9cd8d

Please sign in to comment.