OSDN Git Service

Exclude the padded NULL when comparing the file size
authorGary Ching-Pang Lin <glin@suse.com>
Wed, 24 Jun 2015 09:51:44 +0000 (17:51 +0800)
committerPeter Jones <pjones@redhat.com>
Wed, 24 Jun 2015 13:59:27 +0000 (09:59 -0400)
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 <glin@suse.com>
src/vars.c

index ca0236e..b0006e1 100644 (file)
@@ -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;