From: Lennart Poettering Date: Mon, 16 Dec 2019 11:07:06 +0000 (+0100) Subject: efivars: properly NUL terminate EFI variables when reading X-Git-Tag: v245-rc1~257 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=861f1789051d90f13bab8b7d73283f206bb99636;p=thirdparty%2Fsystemd.git efivars: properly NUL terminate EFI variables when reading A follow-up for 35b9eb0a72b6254568a294f0ebd011da20958a64. --- 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;