Commit Graph

20 Commits

Author SHA1 Message Date
Peter Jones
aedb8470bd Fix up a bunch of our license statements and add SPDX most places
The license statements in our source files were getting to be a giant
mess, and mostly they all just say the same thing.  I've switched most
of it to SPDX labels, but left copyright statements in place (where they
were not obviously incorrect copy-paste jobs that I did...).

If there's some change here you don't think is valid, let me know and
we can fix it up together.

Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16 09:12:48 +01:00
Laszlo Ersek
c6bedd5b83 translate_slashes(): don't write to string literals
Currently, all three invocations of the translate_slashes() function may
lead to writes to the string literal that is #defined with the
DEFAULT_LOADER_CHAR macro. According to ISO C99 6.4.5p6, this is undefined
behavior ("If the program attempts to modify such an array, the behavior
is undefined").

This bug crashes shim on e.g. the 64-bit ArmVirtQemu platform ("Data
abort: Permission fault"), where the platform firmware maps the .text
section (which contains the string literal) read-only.

Modify translate_slashes() so that it copies and translates characters
from an input array of "char" to an output array of "CHAR8".

While at it, fix another bug. Before this patch, if translate_slashes()
ever encountered a double backslash (translating it to a single forward
slash), then the output would end up shorter than the input. However, the
output was not NUL-terminated in-place, therefore the original string
length (and according trailing garbage) would be preserved. After this
patch, the NUL-termination on contraction is automatic, as the output
array's contents are indeterminate when entering the function, and so we
must NUL-terminate it anyway.

Fixes: 8e9124227d
Fixes: e62b69a5b0
Fixes: 3d79bcb265
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1795654
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Upstream-commit-id: 9813e8bc8b3
2020-07-23 20:53:24 -04:00
Gary Lin
c2f645c7cd httpboot: show the error message for the ChildHandle
Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 0fd3c7e8518
2020-07-23 20:51:18 -04:00
Gary Lin
80e52895f2 httpboot: allow the IPv4 gateway to be empty
The gateway is not mandatory.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 69089e9c678
2020-07-23 20:51:18 -04:00
Gary Lin
0ba6c87bdf httpboot: print more messages when it fails to set IP
We previously only print the return status and it may not be clear
enough in some situations. Print the IP address and the gateway to help
the user to identify the possible errors.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 3abe94516c7
2020-07-23 20:51:18 -04:00
Gary Lin
8a66f5571b httpboot: return EFI_NOT_FOUND when it fails to find the NIC handle
httpboot_fetch_buffer() should return EFI_NOT_FOUND to reflect the error
status when get_nic_handle() returns NULL.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 2be5c7dc4b0
2020-07-23 20:51:18 -04:00
Peter Jones
dd712378a7 shim: make everything use a common perror() call.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
9fdca5bbe1 Don't use uefi_call_wrapper(), ever.
I'm pretty done with typing uefi_call_wrapper() and counting arguments
every time.  Instead, just make the compiler error if we don't have
ms_abi.  Also, make it so nothing can use uefi_call_wrapper() directly.

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
1c2376338d shim: Use EFI_ERROR() instead of comparing to EFI_SUCCESS everywhere.
Also consistently name our status variable "efi_status" unless there's a
good reason not to, such as already having another one of those.

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
b953468e91 Don't have tons of local guid definitions for no reason at all.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
dc62a3c4dc Move includes around to clean the source tree up a bit.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Gary Lin
62d8397202 httpboot: include console.h
in_protocol is declared in console.h, so httpboot.c has to include the
header.

Signed-off-by: Gary Lin <glin@suse.com>
2018-02-28 14:47:15 -05:00
Gary Lin
736af67122 httpboot: fix the infinite loop
We should get out of the loop once the uri node is not the last node in
the device path.

Signed-off-by: Gary Lin <glin@suse.com>
2018-02-28 14:47:12 -05:00
Gary Lin
a752290c38 httpboot: Amend the device path matching rule
Originally, we check if the last 2 nodes in the device path are
IPv4()/Uri() or IPv6()/Uri() to determine whether httpboot is used or
not. However, since UEFI 2.7, the DNS node will be inserted between the
IP node and the URI node if the server provides the DNS server address.
This commit changes the matching rule to search IP node and URI node
and ignore any node between those two nodes.

Signed-off-by: Gary Lin <glin@suse.com>
2018-02-28 14:47:12 -05:00
Peter Jones
97a3f6cf94 "in_protocol" is used in more than shim.o; make it not static.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-12-19 16:52:01 -05:00
Lans Zhang
7d745e49c0 httpboot: fix OVMF crash
This is a typical typo. The free operation should be done if uri
was allocated.

Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-07-17 13:13:00 -04:00
Peter Jones
d00ea5558e Fix some i386 type casting errors
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-03-27 14:16:42 -04:00
Gary Lin
3ee08dde9c httpboot: parse https prefix in the uri
This commit adds the check for "https://" in the uri to support HTTPs
Boot.

Signed-off-by: Gary Lin <glin@suse.com>
2017-03-24 18:27:48 -04:00
Peter Jones
83c62ff582 Fix some type errors gcc7 finds in http boot code.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-02-27 15:45:54 -05:00
Gary Ching-Pang Lin
3d79bcb265 Add the optional HTTPBoot support
This commit adds the basic support for HTTPBoot, i.e. to fetch
the next stage loader with the HTTP protocol.

It requires gnu-efi >= 3.0.3 to support the URI device path and
Ip4Config2 or Ip6Config protocol support in the UEFI implementation.

To build shim.efi with HTTPBoot support:
make ENABLE_HTTPBOOT=1 shim.efi

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2016-09-06 14:49:52 -04:00