chiark / gitweb /
sd-device: fix invalid property strv pointers
authorMartin Pitt <martin.pitt@ubuntu.com>
Mon, 1 Jun 2015 09:32:39 +0000 (11:32 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:01:17 +0000 (10:01 +0100)
commit1c0f0483c0afbdde3eaf220eb4e0015533dba3b5
tree098223492f6b413d3cf9967c31f834fde0a1943f
parenta60149bda6fb245c1ed2422a92027a7a0b1b40de
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/libelogind/sd-device/device-private.c