1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

efivars: properly NUL terminate EFI variables when reading

A follow-up for 35b9eb0a72.
This commit is contained in:
Lennart Poettering 2019-12-16 12:07:06 +01:00
parent e40b4caa1f
commit 861f178905

View File

@ -93,8 +93,8 @@ int efi_get_variable(
assert(n <= st.st_size - 4);
/* Always NUL terminate (2 bytes, to protect UTF-16) */
((char*) buf)[n - 4] = 0;
((char*) buf)[n - 4 + 1] = 0;
((char*) buf)[n] = 0;
((char*) buf)[n + 1] = 0;
} else
/* Assume that the reported size is accurate */
n = st.st_size - 4;