mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
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
(cherry picked from commit d0f4e583bf
)
This commit is contained in:
parent
d8d0ac7b5d
commit
6887791e18
@ -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