From 407a27c4fa14f1637e5af877cccb277874c9f435 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 25 Jun 2015 09:33:43 -0400 Subject: [PATCH] Make vars_del_variable() set errno when the variable size is bad. Commit eaaedefb correctly changes this code path so that it tests the file size correctly, but errno is still untouched, so from the consumer's point of view, if the real error *does* occur, you'll get something like: Could not delete variable: Success which is obviously nonsense. Instead, errno should be something about the size. So I picked EFBIG. Signed-off-by: Peter Jones --- src/vars.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vars.c b/src/vars.c index b0006e1..d94c680 100644 --- a/src/vars.c +++ b/src/vars.c @@ -345,9 +345,14 @@ vars_del_variable(efi_guid_t guid, const char *name) 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))) + if (rc < 0) + goto err; + + if (buf_size != sizeof(efi_kernel_variable_64_t) && + buf_size != sizeof(efi_kernel_variable_32_t)) { + errno = EFBIG; goto err; + } close(fd); fd = open(VARS_PATH "del_var", O_WRONLY); -- 2.11.0