summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-12-16 12:07:06 +0100
committerLennart Poettering <lennart@poettering.net>2019-12-16 15:35:31 +0100
commit861f1789051d90f13bab8b7d73283f206bb99636 (patch)
tree85c64f9be8702ac5ecf5257d598112392dad219d
parentbasic/tmpfile: avoid maybe-uninitialized warning in mkostemp_safe() (diff)
downloadsystemd-861f1789051d90f13bab8b7d73283f206bb99636.tar.xz
systemd-861f1789051d90f13bab8b7d73283f206bb99636.zip
efivars: properly NUL terminate EFI variables when reading
A follow-up for 35b9eb0a72b6254568a294f0ebd011da20958a64.
-rw-r--r--src/basic/efivars.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/basic/efivars.c b/src/basic/efivars.c
index bfde67a883..ea43abd7b3 100644
--- a/src/basic/efivars.c
+++ b/src/basic/efivars.c
@@ -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;