]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/shared/logs-show.c
alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhere
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Oct 2021 10:38:37 +0000 (12:38 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 14 Oct 2021 13:57:52 +0000 (15:57 +0200)
commit2f82562bad423d1190912a4b209647dfac966db2
tree766d61a085ee9674d8034351a83f64bcdf5d45bb
parent5222651ecc6f46391e5e0d9cf19793bfe65b0ec8
alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhere

Let's define two helpers strdupa_safe() + strndupa_safe() which do the
same as their non-safe counterparts, except that they abort if called
with allocations larger than ALLOCA_MAX.

This should ensure that all our alloca() based allocations are subject
to this limit.

afaics glibc offers three alloca() based APIs: alloca() itself,
strndupa() + strdupa(). With this we have now replacements for all of
them, that take the limit into account.
60 files changed:
coccinelle/strdupa.cocci [new file with mode: 0644]
src/backlight/backlight.c
src/basic/alloc-util.h
src/basic/cgroup-util.c
src/basic/env-util.c
src/basic/fs-util.c
src/basic/log.c
src/basic/mkdir.c
src/basic/mountpoint-util.c
src/basic/parse-util.c
src/basic/path-lookup.c
src/basic/percent-util.c
src/basic/procfs-util.c
src/basic/time-util.c
src/boot/bless-boot.c
src/core/cgroup.c
src/core/dbus-execute.c
src/core/dbus-util.c
src/core/execute.c
src/coredump/coredump-vacuum.c
src/home/homed-manager.c
src/home/homework-cifs.c
src/home/homework-directory.c
src/home/homework-luks.c
src/journal-remote/journal-remote-main.c
src/journal-remote/journal-upload.c
src/journal/journalctl.c
src/libsystemd/sd-bus/bus-message.c
src/libsystemd/sd-bus/bus-objects.c
src/libsystemd/sd-bus/bus-socket.c
src/libsystemd/sd-bus/sd-bus.c
src/libsystemd/sd-device/sd-device.c
src/libsystemd/sd-journal/sd-journal.c
src/locale/keymap-util.c
src/machine/machine-dbus.c
src/network/generator/network-generator.c
src/nspawn/nspawn-settings.c
src/portable/portable.c
src/resolve/resolvectl.c
src/shared/bus-get-properties.c
src/shared/bus-unit-procs.c
src/shared/bus-unit-util.c
src/shared/dns-domain.c
src/shared/journal-importer.c
src/shared/logs-show.c
src/shared/pager.c
src/shared/selinux-util.c
src/shared/tpm2-util.c
src/shared/uid-range.c
src/socket-proxy/socket-proxyd.c
src/sysv-generator/sysv-generator.c
src/test/test-calendarspec.c
src/test/test-hexdecoct.c
src/test/test-hostname-util.c
src/test/test-path-util.c
src/test/test-string-util.c
src/timedate/timedatectl.c
src/udev/dmi_memory_id/dmi_memory_id.c
src/udev/udev-builtin-path_id.c
src/udev/udev-event.c