]> git.puffer.fish Git - matthieu/frr.git/commit
lib: Fix privs syscaps (pset_t) allocation
authorMartin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
Wed, 8 Jan 2025 09:38:56 +0000 (10:38 +0100)
committerMartin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
Wed, 8 Jan 2025 09:38:56 +0000 (10:38 +0100)
commit4ed9147d98985acb5b3347ad70b31de578ac2289
tree12df29c7612c3a58397f952dd78c855b2e690b4a
parent21fe1f4d83502ac1c2262913c1a98441ea89bf24
lib: Fix privs syscaps (pset_t) allocation

Don't over-allocate syscaps in zcaps2sys(): This is just a single struct
(pset_t) with a count and a pointer to an array of capabilities, not an
array. So only allocate a single pset_t, not num copies of it.

The allocation size of syscaps->caps then needs to be based on the number of
Linux capabilities (count), but that is already handled properly a few lines
below.

Note that this fix is mostly cosmetic and for correctness. There was no
potential for memory corruption, because num is guaranteed to be nonzero. So
at least the one required pset_t was always allocated (but potentially much
more).

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
lib/privs.c