Skip to content

Commit

Permalink
libprocstat: Use calloc for procstat_getcompartments output buffer
Browse files Browse the repository at this point in the history
This ensures the trailing bytes of the compartment name are always
zeroed in the output buffer.
  • Loading branch information
bsdjhb committed Jan 25, 2025
1 parent cf628ae commit 55dff04
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libprocstat/libprocstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ procstat_getcompartments(struct procstat *procstat, struct kinfo_proc *kp,
}

/* Unpack elements of the input buffer into the output buffer. */
outbuf = malloc(n * sizeof(*outbuf));
outbuf = calloc(n, sizeof(*outbuf));
if (outbuf == NULL)
goto out_free;
for (i = 0, cur = 0; i < n; ++i) {

Check warning on line 467 in lib/libprocstat/libprocstat.c

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
Expand Down

0 comments on commit 55dff04

Please sign in to comment.