Fix TFTP reading of zero-size files:
authornaddy <naddy@openbsd.org>
Tue, 30 Jan 2018 20:19:06 +0000 (20:19 +0000)
committernaddy <naddy@openbsd.org>
Tue, 30 Jan 2018 20:19:06 +0000 (20:19 +0000)
commite56d6e58fff7e8a178d8a49b2e92b90d06f420eb
tree4ca05a81d394a123a1c60d56cfb5a349511db416
parent544a27041b454910782e3cf3b3673938dffaa3b6
Fix TFTP reading of zero-size files:

The AllocatePages EFI call returns an error when the allocation
size is 0.  Skip allocating memory and actually transferring the
file when it is empty.

Properly return the number of unread bytes so that a read() of n
bytes does not return n if no bytes were read.

While here, disallow lseek() beyond the TFTP file buffer for SEEK_CUR
as we already do for SEEK_SET.

ok patrick@
sys/arch/amd64/stand/efiboot/conf.c
sys/arch/amd64/stand/efiboot/efipxe.c
sys/arch/arm64/stand/efiboot/conf.c
sys/arch/arm64/stand/efiboot/efipxe.c