]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-device: fix invalid property strv pointers
authorMartin Pitt <martin.pitt@ubuntu.com>
Mon, 1 Jun 2015 09:32:39 +0000 (11:32 +0200)
committerMartin Pitt <martin.pitt@ubuntu.com>
Mon, 1 Jun 2015 10:04:37 +0000 (12:04 +0200)
commitd854ba50a82f28b776c670d27156f0e9881fde8a
tree9d33921ac92399c15fc79feb43899eeb21bd7082
parent19672f1e5fd23ec3ea5b93b8268ae07f2b8e9645
sd-device: fix invalid property strv pointers

In device_update_properties_bufs(), the strv is built from pointers into the
single nul-terminated buf_nulstr string, to avoid allocating the key=value
strings twice. However, we must not do that while building and
GREEDY_REALLOC0()'ing buf_nulstr, as each time when this actually reallocates
memory the pointers we wrote into buf_strv so far become invalid.

So change the logic to first completely build the new buf_nulstr, and then
iterate over it to pick out the pointers to the individual key=value strings
for properties_strv.

This fixes invalid environment for udev callouts.
src/libsystemd/sd-device/device-private.c