sd-bus: make bus_error_message() a thread-safe macro
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 Oct 2022 13:56:25 +0000 (15:56 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Oct 2022 14:59:00 +0000 (16:59 +0200)
commiteaaf7465ee6afd621df639f583b5affebd306e9c
treed8a46df76caa17a5ac8b35de6443c920baa91569
parenta390b03089470582411ca2c36ea91ec503d2a024
sd-bus: make bus_error_message() a thread-safe macro

strerror_r() is used instead of strerror(). The usual trick is employed: we
allocate a buffer that lives until the end of the surrounding block to provide
the scratch space. This change is particularly important forn sd-bus and the
pam modules, which may be called from threaded code.

I checked the codebase, and we only use bus_error_message() in log statements,
so the returned pointer is not used beyond its valid lifetime.
src/libsystemd/sd-bus/bus-error.c
src/libsystemd/sd-bus/bus-error.h