From eaaedefb82e88077f35f230994b9325e09550c8e Mon Sep 17 00:00:00 2001 From: Gary Ching-Pang Lin Date: Wed, 24 Jun 2015 17:51:44 +0800 Subject: [PATCH] Exclude the padded NULL when comparing the file size In vars_del_variable(), this "if" statement always failed because read_file() returned the actual file size +1. if (rc < 0 || (buf_size != sizeof(efi_kernel_variable_64_t) && buf_size != sizeof(efi_kernel_variable_32_t))) Signed-off-by: Gary Ching-Pang Lin --- src/vars.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vars.c b/src/vars.c index ca0236e..b0006e1 100644 --- a/src/vars.c +++ b/src/vars.c @@ -344,6 +344,7 @@ vars_del_variable(efi_guid_t guid, const char *name) goto err; rc = read_file(fd, &buf, &buf_size); + buf_size -= 1; /* read_file pads out 1 extra byte to NUL it */ if (rc < 0 || (buf_size != sizeof(efi_kernel_variable_64_t) && buf_size != sizeof(efi_kernel_variable_32_t))) goto err; -- 2.11.0