Skip to content

Commit

Permalink
Fix setrlimit so it allocates and copies the right number of bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
byteit101 authored and sionescu committed Nov 11, 2022
1 parent 3152d57 commit fa8c99d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/spawnattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,17 @@ lfp_spawnattr_setrlimit(lfp_spawnattr_t *attr, const lfp_rlimit_t *rlim, size_t
SYSCHECK(EFAULT, attr == NULL || rlim == NULL);
SYSCHECK(EINVAL, rlim_size == 0);
attr->flags |= LFP_SPAWN_SETRLIMIT;
lfp_rlimit_t *copy = malloc(rlim_size);
size_t size = rlim_size * sizeof(lfp_rlimit_t);
lfp_rlimit_t *copy = malloc(size);
if (copy == NULL) return -1;
memcpy(copy, rlim, rlim_size);
memcpy(copy, rlim, size);
if (attr->rlim)
free(attr->rlim);
attr->rlim = copy;
attr->rlim_size = rlim_size;
return 0;
}



int lfp_spawn_apply_attributes(const lfp_spawnattr_t *attr)
{
Expand Down

0 comments on commit fa8c99d

Please sign in to comment.