Use read_full_file_full() in read_smbios11_field()

read_virtual_file() will only read up to page size bytes of data
from /sys/firmware/dmi/entries/.../raw so let's use read_full_file_full()
instead to make sure we read all data.

This should be safe since smbios11 data can be considered immutable
during the lifetime of the system.
This commit is contained in:
Daan De Meyer 2024-06-28 20:12:51 +02:00 committed by Luca Boccassi
parent 0e445aaa85
commit 713e68b13c

View file

@ -33,11 +33,7 @@ int read_smbios11_field(unsigned i, size_t max_size, char **ret_data, size_t *re
assert_cc(offsetof(struct dmi_field_header, contents) == 5);
r = read_virtual_file(
p,
max_size >= SIZE_MAX - offsetof(struct dmi_field_header, contents) ? SIZE_MAX :
sizeof(dmi_field_header) + max_size,
(char**) &data, &size);
r = read_full_file_full(AT_FDCWD, p, /* offset = */ 0, max_size, /* flags = */ 0, NULL, (char**) &data, &size);
if (r < 0)
return r;