From 861f1789051d90f13bab8b7d73283f206bb99636 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 16 Dec 2019 12:07:06 +0100 Subject: [PATCH] efivars: properly NUL terminate EFI variables when reading A follow-up for 35b9eb0a72b6254568a294f0ebd011da20958a64. --- src/basic/efivars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/efivars.c b/src/basic/efivars.c index bfde67a883b..ea43abd7b3f 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; -- 2.39.5