SHA256
1
0
forked from pool/grub2
grub2/0001-30_uefi-firmware-fix-printf-format-with-null-byte.patch
Michael Chang a3bdb368a2 Accepting request 904721 from home:michael-chang:grub:2.06
- Version bump to 2.06
  * rediff
    - 0001-add-support-for-UEFI-network-protocols.patch
    - 0002-net-read-bracketed-ipv6-addrs-and-port-numbers.patch
    - 0003-Make-grub_error-more-verbose.patch
    - 0003-bootp-New-net_bootp6-command.patch
    - 0005-grub.texi-Add-net_bootp6-doument.patch
    - 0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch
    - 0006-efi-Set-image-base-address-before-jumping-to-the-PE-.patch
    - 0008-efinet-Setting-DNS-server-from-UEFI-protocol.patch
    - 0046-squash-verifiers-Move-verifiers-API-to-kernel-image.patch
    - grub-install-force-journal-draining-to-ensure-data-i.patch
    - grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
    - grub2-diskfilter-support-pv-without-metadatacopies.patch
    - grub2-efi-HP-workaround.patch
    - grub2-efi-xen-cfg-unquote.patch
    - grub2-efi-xen-chainload.patch
    - grub2-fix-menu-in-xen-host-server.patch
    - grub2-gfxmenu-support-scrolling-menu-entry-s-text.patch
    - grub2-install-remove-useless-check-PReP-partition-is-empty.patch
    - grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch
    - grub2-mkconfig-default-entry-correction.patch
    - grub2-pass-corret-root-for-nfsroot.patch
    - grub2-s390x-03-output-7-bit-ascii.patch
    - grub2-s390x-04-grub2-install.patch
    - grub2-secureboot-install-signed-grub.patch
    - grub2-setup-try-fs-embed-if-mbr-gap-too-small.patch
    - use-grub2-as-a-package-name.patch
  * update by patch squashed:
    - 0001-Add-support-for-Linux-EFI-stub-loading-on-aarch64.patch

OBS-URL: https://build.opensuse.org/request/show/904721
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=386
2021-07-08 09:03:14 +00:00

89 lines
3.0 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 47eddcfc6859f269bb3cfaf95d5b33502cafd9ec Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Mon, 21 Jun 2021 05:11:18 +0000
Subject: [PATCH] 30_uefi-firmware: fix printf format with null byte
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On a Raspberry Pi 4, the OsIndications variable is set as following
$ od -An -t u1 /sys/firmware/efi/efivars/OsIndicationsSupported-8be4df61-93ca-11d2-aa0d-00e098032b8c
6 0 0 0 0 0 0 0 0 0 0 0
The fifth byte indicates there's no boot to uefi firmware support as no
bit is set. However the /etc/grub.d/30_uefi-firmware mistakenly detects
that from the grub-mkconfig output.
/etc/grub.d/30_uefi-firmware: line 34: warning: command substitution: ignored null byte in input
Adding boot menu entry for UEFI Firmware Settings ...
The warning has dictated that the null byte is ignored from the printf
input arguments so that the expression of
rintf 0x%x \'"$(cat $OS_INDICATIONS | cut -b5)"\')
becomes
printf 0x%x \'""\'
0x27
The numeric value of trailing character \' is outputted instead of the
null byte.
From the printf manual, there's description to the synax of formatting
the numeric value ouput of a character.
"If the leading character of a numeric argument is " or ' then its
value is the numeric value of the immediately following character. Any
remaining characters are silently ignored if the POSIXLY_CORRECT
environment variable is set; otherwise, a warning is printed. For
example, printf "%d" "'a" outputs 97 on hosts that use the ASCII
character set, since a has the numeric value 97 in ASCII."
From the descrption the trailing \' appears to be superfluous and should
get removed to have correct output.
printf 0x%x \'""
0x0
In additon to suppress the warning message of ignored null byte in
input, we can delete it so an empty string is used.
To illustrate the problem using echo as example
printf 0x%x \'"$(echo -e '\x00')"
-bash: warning: command substitution: ignored null byte in input
0x0
And here using tr to delete the null character
printf 0x%x \'"$(echo -e '\x00'| tr -d '\000')"
The expression above is substituted to
printf 0x%x \'""
0x0
Signed-off-by: Michael Chang <mchang@suse.com>
---
util/grub.d/30_uefi-firmware.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in
index d344d3883..d069f2727 100644
--- a/util/grub.d/30_uefi-firmware.in
+++ b/util/grub.d/30_uefi-firmware.in
@@ -31,7 +31,7 @@ EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c
OS_INDICATIONS="$EFI_VARS_DIR/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE"
if [ -e "$OS_INDICATIONS" ] && \
- [ "$(( $(printf 0x%x \'"$(cat $OS_INDICATIONS | cut -b5)"\') & 1 ))" = 1 ]; then
+ [ "$(( $(printf 0x%x \'"$(cat $OS_INDICATIONS | cut -b5 | tr -d '\000')") & 1 ))" = 1 ]; then
LABEL="UEFI Firmware Settings"
gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2
--
2.26.2