efivar: handle error when reading --fromfile
The result of read() was stored in an unsigned variable, so the test for a negative value would never work. While I'm here, print a better error message for an empty file, omitting the misleading errno message. Reported by: Coverity MFC after: 1 week Sponsored by: Dell EMC Isilon
This commit is contained in:
parent
331b84b5db
commit
d0f4e583bf
@ -239,8 +239,10 @@ print_var(efi_guid_t *guid, char *name)
|
||||
if (data == NULL)
|
||||
rep_err(1, "malloc");
|
||||
datalen = read(fd, data, 64 * 1024);
|
||||
if (datalen <= 0)
|
||||
if ((ssize_t)datalen < 0)
|
||||
rep_err(1, "read");
|
||||
if (datalen == 0)
|
||||
rep_errx(1, "empty file");
|
||||
close(fd);
|
||||
} else {
|
||||
rv = efi_get_variable(*guid, name, &data, &datalen, &att);
|
||||
|
Loading…
Reference in New Issue
Block a user