mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
sd-device: fix double-free
If an attribute is read but the value is not used (i.e. ret_value is NULL), then sd_device_get_sysattr_value() mistakenly frees the read data even though it is cached internally. Fixes a bug introduced by acfc2a1d15560084e077ffb3be472cd117e9020a. Fixes #25702. (cherry picked from commit eb18e7b7825e8320bb4d6269690ef8c3f5461d2b) (cherry picked from commit aeb36537443272f0bf73dd672837eabcecb34f3a)
This commit is contained in:
parent
f2f863c51f
commit
8f4d5828aa
@ -2166,12 +2166,17 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
|
||||
sysattr, value, ret_value ? "" : ", ignoring");
|
||||
if (ret_value)
|
||||
return r;
|
||||
} else if (ret_value)
|
||||
*ret_value = TAKE_PTR(value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ret_value)
|
||||
*ret_value = value;
|
||||
|
||||
TAKE_PTR(value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device_get_sysattr_unsigned(sd_device *device, const char *sysattr, unsigned *ret_value) {
|
||||
const char *value;
|
||||
int r;
|
||||
|
Loading…
x
Reference in New Issue
Block a user