HomeFreeBSD

etc/systemd/zfs-mount-generator: avoid strndupa

Description

etc/systemd/zfs-mount-generator: avoid strndupa

The non-standard strndupa function is not implemented by musl libc,
and can be dangerous due to its potential to blow the stack. (musl
_does_ implement strdupa, used elsewhere in this function.)

With a similar amount of code, we can use a heap allocation to
construct the pool name, which is musl-friendly and doesn't have
potential stack problems.

(Why care about musl when systemd only supports glibc? Some distros
patch systemd with portability fixes, and it would be nice to be able
to use ZFS on those distros.)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com>
Closes #14327

Details

Provenance
Alyssa Ross <alyssa.ross@unikie.com>Authored on Jan 10 2023, 9:40 PM
GitHub <noreply@github.com>Committed on Jan 10 2023, 9:40 PM
Parents
rGfc45975ec868: Batch enqueue/dequeue for bqueue
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rG1f19826c9ac8: etc/systemd/zfs-mount-generator: avoid strndupa (authored by Alyssa Ross <alyssa.ross@unikie.com>).Jan 10 2023, 9:40 PM