diff options
Diffstat (limited to 'debian')
| -rw-r--r-- | debian/changelog | 2 | ||||
| -rw-r--r-- | debian/patches/netboot-cleanup | 106 | ||||
| -rw-r--r-- | debian/patches/series | 1 | ||||
| -rw-r--r-- | debian/patches/tftp-proper-nul-termination | 2 |
4 files changed, 110 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog index 16791a50..33f1bee1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ shim (0.4-0ubuntu4) UNRELEASED; urgency=low warnings in netboot.c. * debian/patches/tftp-proper-nul-termination: fix nul termination errors in filenames passed to tftp. + * debian/patches/netboot-cleanup: roll-up of miscellaneous fixes to + the netboot code. -- Steve Langasek <steve.langasek@ubuntu.com> Fri, 20 Sep 2013 14:43:23 +0000 diff --git a/debian/patches/netboot-cleanup b/debian/patches/netboot-cleanup new file mode 100644 index 00000000..e94e2c7d --- /dev/null +++ b/debian/patches/netboot-cleanup @@ -0,0 +1,106 @@ +Description: roll-up of miscellaneous fixes to the netboot code + Pull of various fixes from + <https://github.com/vorlonofportland/shim/tree/netboot-cleanup>, currently + awaiting merge upstream. +Author: Steve Langasek <steve.langasek@ubuntu.com> + +Index: shim/netboot.c +=================================================================== +--- shim.orig/netboot.c ++++ shim/netboot.c +@@ -141,11 +141,11 @@ + return rc; + } + +-static char *get_v6_bootfile_url(EFI_PXE_BASE_CODE_DHCPV6_PACKET *pkt) ++static CHAR8 *get_v6_bootfile_url(EFI_PXE_BASE_CODE_DHCPV6_PACKET *pkt) + { + void *optr; + EFI_DHCP6_PACKET_OPTION *option; +- char *url; ++ CHAR8 *url; + UINT32 urllen; + + optr = pkt->DhcpOptions; +@@ -159,10 +159,9 @@ + if (ntohs(option->OpCode) == 59) { + /* This is the bootfile url option */ + urllen = ntohs(option->Length); +- url = AllocatePool(urllen+2); ++ url = AllocateZeroPool(urllen+1); + if (!url) + return NULL; +- memset(url, 0, urllen+2); + memcpy(url, option->Data, urllen); + return url; + } +@@ -225,17 +224,17 @@ + return (UINT8 *)ip; + } + +-static BOOLEAN extract_tftp_info(char *url) ++static BOOLEAN extract_tftp_info(CHAR8 *url) + { + CHAR8 *start, *end; +- char ip6str[128]; ++ char ip6str[40]; + CHAR8 *template = (CHAR8 *)"/grubx64.efi"; + + if (strncmp((UINT8 *)url, (UINT8 *)"tftp://", 7)) { + Print(L"URLS MUST START WITH tftp://\n"); + return FALSE; + } +- start = (CHAR8 *)url + 7; ++ start = url + 7; + if (*start != '[') { + Print(L"TFTP SERVER MUST BE ENCLOSED IN [..]\n"); + return FALSE; +@@ -245,12 +244,16 @@ + end = start; + while ((*end != '\0') && (*end != ']')) { + end++; ++ if (end - start > 39) { ++ Print(L"TFTP URL includes malformed IPv6 address\n"); ++ return FALSE; ++ } + } + if (end == '\0') { + Print(L"TFTP SERVER MUST BE ENCLOSED IN [..]\n"); + return FALSE; + } +- memset(ip6str, 0, 128); ++ memset(ip6str, 0, 40); + memcpy(ip6str, start, end - start); + end++; + memcpy(&tftp_addr.v6, str2ip6(ip6str), 16); +@@ -270,14 +273,16 @@ + static EFI_STATUS parseDhcp6() + { + EFI_PXE_BASE_CODE_DHCPV6_PACKET *packet = (EFI_PXE_BASE_CODE_DHCPV6_PACKET *)&pxe->Mode->DhcpAck.Raw; +- char *bootfile_url; +- ++ CHAR8 *bootfile_url; + + bootfile_url = get_v6_bootfile_url(packet); +- if (extract_tftp_info(bootfile_url) == FALSE) +- return EFI_NOT_FOUND; + if (!bootfile_url) + return EFI_NOT_FOUND; ++ if (extract_tftp_info(bootfile_url) == FALSE) { ++ FreePool(bootfile_url); ++ return EFI_NOT_FOUND; ++ } ++ FreePool(bootfile_url); + return EFI_SUCCESS; + } + +@@ -350,6 +355,8 @@ + goto try_again; + } + ++ if (rc != EFI_SUCCESS && *buffer) { ++ FreePool(*buffer); ++ } + return rc; +- + } diff --git a/debian/patches/series b/debian/patches/series index cd7c5012..f37a5e39 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -7,3 +7,4 @@ fix-tftp-prototype build-with-Werror fix-compiler-warnings tftp-proper-nul-termination +netboot-cleanup diff --git a/debian/patches/tftp-proper-nul-termination b/debian/patches/tftp-proper-nul-termination index 7345cfc5..0a105d86 100644 --- a/debian/patches/tftp-proper-nul-termination +++ b/debian/patches/tftp-proper-nul-termination @@ -34,7 +34,7 @@ Index: shim/netboot.c memset(ip6str, 0, 128); - memcpy(ip6str, start, strlen((UINT8 *)start)); - *end = ']'; -+ memcpy(ip6str, start, end + 1 - start); ++ memcpy(ip6str, start, end - start); end++; memcpy(&tftp_addr.v6, str2ip6(ip6str), 16); - full_path = AllocatePool(strlen((UINT8 *)end)+strlen((UINT8 *)template)+1); |
