mirror of
https://github.com/systemd/systemd
synced 2026-03-19 19:44:48 +01:00
Compare commits
2 Commits
d3a047b9d1
...
9952f11a84
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9952f11a84 | ||
|
|
70160c6eee |
@ -2022,13 +2022,17 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
|
|||||||
/* skip non-readable files */
|
/* skip non-readable files */
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
else {
|
else {
|
||||||
/* read attribute value */
|
size_t size;
|
||||||
r = read_full_virtual_file(path, &value, NULL);
|
|
||||||
|
/* Read attribute value, Some attributes contain embedded '\0'. So, it is necessary to
|
||||||
|
* also get the size of the result. See issue #20025. */
|
||||||
|
r = read_full_virtual_file(path, &value, &size);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
/* drop trailing newlines */
|
/* drop trailing newlines */
|
||||||
delete_trailing_chars(value, "\n");
|
while (size > 0 && strchr(NEWLINE, value[--size]))
|
||||||
|
value[size] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unfortunately, we need to return 'const char*' instead of 'char*'. Hence, failure in caching
|
/* Unfortunately, we need to return 'const char*' instead of 'char*'. Hence, failure in caching
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user