summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-06-28 20:12:51 +0200
committerLennart Poettering <lennart@poettering.net>2024-07-01 18:52:14 +0200
commit53ee7e0aa163d2ba2eccef3ec8467ac635b8929d (patch)
tree5b9a554ea26ed2dbbfafcd14b1352f84ec38b2ef /src/shared
parentMerge pull request #33553 from poettering/list-devices (diff)
downloadsystemd-53ee7e0aa163d2ba2eccef3ec8467ac635b8929d.tar.xz
systemd-53ee7e0aa163d2ba2eccef3ec8467ac635b8929d.zip
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.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/smbios11.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/shared/smbios11.c b/src/shared/smbios11.c
index 5009427810..bea4f7f1ee 100644
--- a/src/shared/smbios11.c
+++ b/src/shared/smbios11.c
@@ -33,10 +33,15 @@ 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,
+ /* We don't use read_virtual_file() because it only reads a single page of bytes from the DMI sysfs
+ * file. Since the SMBIOS data is immutable after boot, it's safe to use read_full_file_full() here. */
+ r = read_full_file_full(
+ AT_FDCWD, p,
+ /* offset = */ UINT64_MAX,
max_size >= SIZE_MAX - offsetof(struct dmi_field_header, contents) ? SIZE_MAX :
sizeof(dmi_field_header) + max_size,
+ /* flags = */ 0,
+ /* bind_name = */ NULL,
(char**) &data, &size);
if (r < 0)
return r;