From 46968b6e6323925be6f29c2770a04a8a1a858082 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 12 Mar 2021 22:54:28 +0100 Subject: [PATCH] Update to 2.06~rc1 to fix a bunch of CVEs Resolves: CVE-2020-14372 Resolves: CVE-2020-25632 Resolves: CVE-2020-25647 Resolves: CVE-2020-27749 Resolves: CVE-2020-27779 Resolves: CVE-2021-20225 Resolves: CVE-2021-20233 Signed-off-by: Javier Martinez Canillas --- ...d-support-for-Linux-EFI-stub-loading.patch | 51 +- 0002-Rework-linux-command.patch | 49 +- 0003-Rework-linux16-command.patch | 18 +- ...ecureboot-support-on-efi-chainloader.patch | 36 +- ...loaders-that-link-in-efi-mode-honor-.patch | 274 +- ...rch-64-on-32-boot-in-linuxefi-loader.patch | 4 +- 0007-re-write-.gitignore.patch | 266 +- ...ient-architecture-CAS-reboot-support.patch | 10 +- ...nsole-display-attr-when-clear-screen.patch | 2 +- ...when-generating-configuration-by-gru.patch | 26 - ...1-Move-bash-completion-script-922997.patch | 6 +- ...o-include-entries-by-title-not-just-.patch | 13 +- ...=> 0013-Make-exit-take-a-return-code.patch | 22 +- 0013-Update-to-minilzo-2.08.patch | 8509 ----------------- ...es-load-an-env-block-from-a-variable.patch | 30 +- 0015-Add-GRUB_DISABLE_UUID.patch | 106 - ...015-Migrate-PPC-from-Yaboot-to-Grub2.patch | 4 +- ...=> 0016-Add-fw_path-variable-revised.patch | 8 +- ...pot-as-binary-so-git-won-t-try-to-di.patch | 19 - ...-hex-hex-straight-through-unmolested.patch | 30 +- ...g-module-to-parse-Boot-Loader-Specif.patch | 159 +- ...patch => 0019-Add-devicetree-loading.patch | 6 +- ...HCP-client-ID-and-UUID-options-added.patch | 140 - ...0-Don-t-write-messages-to-the-screen.patch | 21 +- ...Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch | 38 - ...UEFI-operating-systems-returned-by-o.patch | 46 - ... => 0021-Don-t-print-GNU-GRUB-header.patch | 2 +- ...=> 0022-Don-t-add-to-highlighted-row.patch | 2 +- ...atch => 0023-Message-string-cleanups.patch | 2 +- ...ing-now-that-we-aren-t-displaying-it.patch | 2 +- 0025-Add-X-option-to-printf-functions.patch | 55 - ...t-indentation-for-the-term-help-text.patch | 4 +- ...es.patch => 0026-Indent-menu-entries.patch | 2 +- ...for-specific-config-file-for-netboot.patch | 200 - ...ix-margins.patch => 0027-Fix-margins.patch | 2 +- ...-1-for-our-right-hand-margin-so-line.patch | 2 +- ...0029-Enable-pager-by-default.-985860.patch | 0 ...-on-serial-so-don-t-tell-the-user-to.patch | 2 +- ...n-t-say-GNU-Linux-in-generated-menus.patch | 4 +- ...-Don-t-draw-a-border-around-the-menu.patch | 2 +- ...andard-margin-for-the-timeout-string.patch | 2 +- ...rame-to-list-of-relocations-stripped.patch | 2 +- ...password-to-boot-entries-generated-b.patch | 2 +- ...=> 0036-Don-t-emit-Booting-.-message.patch | 8 +- ...f-man-pages-with-slightly-nicer-ones.patch | 8 +- ...ix-when-fallback-searching-for-grub-.patch | 2 +- ...-before-grub.cfg-on-tftp-config-file.patch | 30 +- ...CLASS-in-10_linux-from-etc-os-releas.patch | 2 +- ...t-ordering-for-.debug-and-rescue-ker.patch | 4 +- ...2-Try-prefix-if-fw_path-doesn-t-work.patch | 34 +- ...-Package-Sort-for-grub2-mkconfig-112.patch | 35 +- ...spaces-when-we-re-doing-our-cmdline-.patch | 33 - ...fig-construct-titles-that-look-like-.patch | 2 +- ...ly-grub2-password-config-tool-985962.patch | 14 +- ... 0046-tcp-add-window-scaling-support.patch | 0 ...net-and-bootp-add-support-for-dhcpv6.patch | 60 +- ...rnel-settings-and-use-it-in-10_linux.patch | 26 +- ...1374141-fix-incorrect-mask-for-ppc64.patch | 0 ...ert-function-to-support-NVMe-devices.patch | 56 - ... 0050-Make-grub_fatal-also-backtrace.patch | 8 +- 0051-Add-grub_util_readlink.patch | 82 - ...ix-up-some-man-pages-rpmdiff-noticed.patch | 6 +- ...se-symlinks-including-those-across-d.patch | 104 - ...fo-pages-say-grub2-where-appropriate.patch | 167 +- ...-chainloader-entries-don-t-try-any-x.patch | 6 +- ...-Add-ability-to-boot-from-subvolumes.patch | 30 +- ...port-btrfs_subvol-and-btrfs_subvolid.patch | 4 +- ...-grub.cfg-netboot-selection-order-11.patch | 66 - ...> 0056-grub2-btrfs-03-follow_default.patch | 20 +- ...=> 0057-grub2-btrfs-04-grub2-install.patch | 12 +- 0058-Handle-rssd-storage-devices.patch | 36 - ...> 0058-grub2-btrfs-05-grub2-mkconfig.patch | 10 +- ... => 0059-grub2-btrfs-06-subvol-mount.patch | 24 +- ...subvol-name-scheme-to-support-old-sn.patch | 4 +- ...-correctly-with-btrfs-snapshots-bsc-.patch | 8 +- ...ocate_pool-and-grub_efi_free_pool-wr.patch | 4 +- ...ue-when-reading-username-and-passwor.patch | 44 - 0063-Add-a-url-parser.patch | 1021 -- ...fi_.-memory-helpers-where-reasonable.patch | 14 +- ...4-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch | 16 +- ...=> 0065-don-t-use-int-for-efi-status.patch | 4 +- 0066-Normalize-slashes-in-tftp-paths.patch | 61 - ...INIT-declare-its-function-prototypes.patch | 2 +- ...-efi-as-HFS-on-ppc-machines-in-grub-.patch | 4 +- ...d-xen-or-multiboot-2-modules-as-need.patch | 32 +- ...-calibration-not-take-51-seconds-to-.patch | 0 ...070-align-struct-efi_variable-better.patch | 2 +- ...fdt-has-address-cells-and-size-cells.patch | 42 - 0071-Add-BLS-support-to-grub-mkconfig.patch | 393 + ...-backtrace-on-grub_abort-for-grub-em.patch | 4 +- ...more-debug-info-in-our-module-loader.patch | 41 - ...nux-and-initrd-commands-for-grub-emu.patch | 18 +- ...h => 0074-Add-grub2-switch-to-blscfg.patch | 57 +- ...patch => 0075-make-better-backtraces.patch | 38 +- ...w-our-startup-message-if-debug-is-se.patch | 4 +- ...-some-minor-include-path-weirdnesses.patch | 0 ...it-possible-to-enabled-build-id-sha1.patch | 6 +- ...f-grub_dprintf-without-the-file-line.patch | 8 +- ...dprintf-that-tells-us-load-addresses.patch | 22 +- ...tch => 0081-Fixup-for-newer-compiler.patch | 4 +- ...-export-the-start-and-_start-symbols.patch | 4 +- ...tch => 0083-Fixup-for-newer-compiler.patch | 2 +- ...pport-for-non-Ethernet-network-cards.patch | 28 +- ...c-sized-arrays-since-we-don-t-build-.patch | 43 - ...racketed-ipv6-addrs-and-port-numbers.patch | 39 +- ...=> 0086-bootp-New-net_bootp6-command.patch | 26 +- 0086-don-t-ignore-const.patch | 22 - ...=> 0087-efinet-UEFI-IPv6-PXE-support.patch | 12 +- ...088-grub.texi-Add-net_bootp6-doument.patch | 12 +- ...essing-DHCPACK-packet-from-HTTP-Boot.patch | 22 +- 0089-editenv-handle-relative-symlinks.patch | 50 - ...e-libgrub.pp-depend-on-config-util.h.patch | 45 - ...etting-network-from-UEFI-device-path.patch | 20 +- ...etting-DNS-server-from-UEFI-protocol.patch | 39 +- ...92-Support-UEFI-networking-protocols.patch | 56 +- ...> 0093-AUDIT-0-http-boot-tracker-bug.patch | 2 +- ...-incr-command-to-increment-integer-v.patch | 6 +- 0095-Add-BLS-support-to-grub-mkconfig.patch | 741 -- ...h => 0095-Add-auto-hide-menu-support.patch | 22 +- ...> 0096-Add-grub-set-bootflag-utility.patch | 10 +- ...b-boot-indeterminate.service-example.patch | 0 ...h => 0098-gentpl-add-disable-support.patch | 2 +- 0099-Add-grub_debug_enabled.patch | 60 - ... => 0099-gentpl-add-pc-firmware-type.patch | 2 +- ...e-the-firmware-acceleration-for-http.patch | 0 ...ot_url-reflect-the-protocol-hostname.patch | 0 ...n-tell-configure-which-cflags-utils-.patch | 10 +- ...make-it-possible-to-run-checkers-on-.patch | 0 ...04-Rework-how-the-fdt-command-builds.patch | 18 +- ...able-non-wordsize-allocations-on-arm.patch | 4 +- ...nd-prefix-when-HTTP-path-is-relative.patch | 4 +- ...=> 0107-Make-grub_error-more-verbose.patch | 57 +- ...eset-an-alias-for-the-reboot-command.patch | 0 ....patch => 0109-Add-a-version-command.patch | 8 +- ...dprintf-and-nerf-dprintf-in-script.c.patch | 8 +- ...lid-character-recongition-in-strto-l.patch | 37 - ...-Better-memory-allocation-and-error-.patch | 47 +- ...tter-locations-for-kernel-and-initrd.patch | 6 +- ...p-all-the-places-Wsign-compare-error.patch | 39 +- ...gn-compare-Wno-conversion-Wno-error-.patch | 8 +- ...ce-buffers-for-reading-to-addresses-.patch | 0 ...-arrange-grub_cmd_linux-a-little-bit.patch | 0 ...e-our-own-allocator-for-kernel-stuff.patch | 4 +- 0118-Fix-one-more-coverity-complaint.patch | 27 - ...itrd-params-cmdline-allocations-abov.patch | 6 +- ... => 0119-Fix-getroot.c-s-trampolines.patch | 2 +- ...not-allow-stack-trampolines-anywhere.patch | 6 +- ...tch => 0121-Reimplement-boot_counter.patch | 8 +- ...efi_gop.c-Add-support-for-BLT_ONLY-a.patch | 56 - ...ntry-selection-based-on-ID-and-title.patch | 0 0122-efi-uga-use-64-bit-for-fb_base.patch | 105 - ...ot-set-text-mode-until-we-actually-n.patch | 184 - ...try-users-option-argument-to-be-opti.patch | 2 +- ...export-env-and-efi-load-env-commands.patch | 42 +- ...grub_console_read_key_stroke-helper-.patch | 102 - ...nsole-Implement-getkeystatus-support.patch | 72 - ...le-to-subtract-conditions-from-debug.patch | 4 +- ...bles-from-the-initial-context-when-c.patch | 0 ...status-helper-funtion-available-ever.patch | 87 - ...d-holding-SHIFT-as-user-interrupt-ke.patch | 94 - ...-boot-success-reset-from-menu-auto-h.patch | 6 +- ...ix-systemctl-kexec-exit-status-check.patch | 0 ...b-emu-linux-loader-messages-as-debug.patch | 0 ...t-boot-commands-will-only-return-on-.patch | 24 +- ...try-for-firmware-setup-on-UEFI-FastB.patch | 94 - ...ferences-for-fdt-when-building-with-.patch | 0 ... => 0132-Do-better-in-bootstrap.conf.patch | 2 +- ...0133-Use-git-to-apply-gnulib-patches.patch | 173 +- ...-error-with-the-fdt-module-on-risc-v.patch | 0 ...g-Update-comment-about-running-as-ro.patch | 0 ...g-Write-new-env-to-tmpfile-and-then-.patch | 0 ...indeterminate-getting-set-on-boot_su.patch | 0 ..._EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch | 0 ...ader-Define-machine-types-for-RISC-V.patch | 4 +- ... => 0140-Add-start-symbol-for-RISC-V.patch | 0 ...conf-Force-autogen.sh-to-use-python3.patch | 10 +- ...-R-.note.gnu.property-at-more-places.patch | 82 - ...fw-http-_path-variables-to-make-them.patch | 4 +- ...ernel_header.hdr_offset-be-at-the-ri.patch | 71 - ...-literal-IPv6-addresses-in-square-br.patch | 0 ...o-specify-a-port-number-in-addresses.patch | 0 ...mprove-check-to-detect-literal-IPv6-.patch | 0 ...-debug-output-on-GOP-and-UGA-probing.patch | 66 - ...debug-message-if-parsing-the-address.patch | 0 ...so-accept-F8-as-a-user-interrupt-key.patch | 30 + ...se-address-before-jumping-to-the-PE-.patch | 16 +- ...ate-TPM-measurement-errors-to-the-ve.patch | 8 +- ...maximum-bounce-buffer-size-to-16-MiB.patch | 2 +- ...fix-when-the-HTTP-path-is-relative-a.patch | 16 +- ...turn-in-efi-export-env-and-efi-load-.patch | 2 +- ...p-fix-some-allocation-error-checking.patch | 0 ...p-fix-some-allocation-error-checking.patch | 0 ...g.c-fix-some-potential-allocation-ov.patch | 0 ...integer-overflows-in-grub_cmd_initrd.patch | 2 +- ...rnel-validation-without-shim-protoco.patch | 16 +- ...ar-pointers-in-grub-core-net-bootp.c.patch | 6 +- ...ointers-in-grub-core-net-efi-ip4_con.patch | 0 ...ointers-in-grub-core-net-efi-ip6_con.patch | 0 ...-end-pointers-have-safer-const-quali.patch | 987 -- ...-pointers-in-grub-core-net-efi-net.c.patch | 0 ...-pointers-in-grub-core-net-efi-pxe.c.patch | 0 ...gration-scripts-to-make-systemctl-re.patch | 10 +- ...ion.sh-Also-set-old-menu_show_once-g.patch | 0 ...set-1-when-keyboard-is-in-Translate-.patch | 2 +- ...g-up-grub.cfg-XXX-while-tftp-booting.patch | 42 - ...ll-disable-support-for-EFI-platforms.patch | 6 +- ...imestamps-configure-flag-to-prepend-.patch | 12 +- ...-to-set-fPIE-and-friends-on-libgnu.a.patch | 40 - ...ements-to-grub_disk_open-and-grub_di.patch | 2 +- ...strtoull-print-an-error-if-no-conver.patch | 31 - 0169-Fix-the-type-of-grub_efi_status_t.patch | 79 - ...on-grub_debug_is_enabled-void-return.patch | 8 +- ...ear-screen-when-debugging-is-enabled.patch | 2 +- ..._-instrumentation-new-file-debug-tag.patch | 0 ...-Avoiding-many-unecessary-open-close.patch | 0 ...-implements-fibre-channel-discovery-.patch | 0 ...erpc-enables-device-mapper-discovery.patch | 0 ...fallback_set-var-to-force-the-set-ma.patch | 2 +- ...igning-grub-with-an-appended-signatu.patch | 118 +- ...find-wholename-for-long-path-matches.patch | 23 - ...rub-Document-signing-grub-under-UEFI.patch | 38 +- ...ap.conf-don-t-clobber-AM_CFLAGS-here.patch | 23 - ...nt-signing-grub-with-an-appended-sig.patch | 25 +- ...e-grub_dl_set_persistent-for-the-emu.patch | 4 +- ...tation-of-pc-relative-relocation-off.patch | 36 - ...patch => 0180-pgp-factor-out-rsa_pad.patch | 6 +- ...Add-support-for-the-devicetree-field.patch | 132 - ...rage-for-grub_crypto_pk_-to-crypto.c.patch | 4 +- ...-var-in-a-BLS-config-if-GRUB_DEFAULT.patch | 38 - ...p-tweaks-in-preparation-for-libtasn1.patch | 0 ...s-option-to-menu-entries-generated-f.patch | 78 - ...0183-libtasn1-import-libtasn1-4.16.0.patch | 0 ...-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch | 45 - ...asn1-disable-code-not-needed-in-grub.patch | 0 ...dcode-an-env-var-as-fallback-for-the.patch | 63 - ...tasn1-changes-for-grub-compatibility.patch | 0 ...86-libtasn1-compile-into-asn1-module.patch | 4 +- ...7-test_asn1-test-module-for-libtasn1.patch | 22 +- ...ce-char-when-appending-fields-for-va.patch | 76 - ...-support-embedding-x509-certificates.patch | 99 +- ...res-import-GNUTLS-s-ASN.1-descriptio.patch | 0 ...res-parse-PKCS-7-signedData-and-X.50.patch | 52 +- ...rt-for-sorting-the-plus-higher-than-.patch | 59 - 0191-Fix-savedefault-with-blscfg.patch | 50 - ...res-support-verifying-appended-signa.patch | 137 +- ...pended-signatures-verification-tests.patch | 123 +- ...93-appended-signatures-documentation.patch | 134 +- ...er-lockdown-based-on-ibm-secure-boot.patch | 109 + 0195-RISC-V-Add-__clzdi2-symbol.patch | 43 - ...-Properly-disable-the-os-prober-by-d.patch | 71 + ...tes-Disable-the-os-prober-by-default.patch | 70 + ...l-Define-default-platform-for-RISC-V.patch | 31 - ...e-the-root-variable-to-search-for-BL.patch | 47 - ...LL-instead-of-a-zero-length-array-in.patch | 38 - ...lscfg-Update-grub2-binary-in-ESP-for.patch | 37 - ...lscfg-Only-mark-GRUB-as-BLS-supporte.patch | 37 - ...e-logic-from-10_linux_bls-and-drop-t.patch | 662 -- ...lscfg-Use-install-to-copy-GRUB-binar.patch | 46 - ...le-BLS-configuration-if-new-kernel-p.patch | 39 - ...fault_kernelopts-variable-as-fallbac.patch | 40 - ...early-exit-due-error-when-reading-pe.patch | 33 - ...r-overrun-when-attempting-to-shrink-.patch | 60 - ...e-cmdline-in-BLS-snippets-instead-of.patch | 160 - ...ore-existence-check-in-get_sorted_bl.patch | 32 - ...-Enable-module-for-all-EFI-platforms.patch | 26 - ...t-update-BLS-files-that-aren-t-manag.patch | 56 - 0221-fix-build-with-rpm-4.16.patch | 30 - ...s-BLS-supported-in-OSTree-systems-wi.patch | 35 - ...t-boot-commands-will-only-return-on-.patch | 40 - ...lexer-fatal-errors-actually-be-fatal.patch | 67 - ...e-arithmetic-primitives-that-check-f.patch | 124 - ...-we-always-have-an-overflow-checking.patch | 240 - 0228-calloc-Use-calloc-at-most-places.patch | 1834 ---- ...low-checking-primitives-where-we-do-.patch | 1320 --- ...on-t-leak-memory-on-realloc-failures.patch | 66 - ...-not-load-more-than-one-NAME-section.patch | 35 - ...fxmenu-Fix-double-free-in-load_image.patch | 33 - ...ree-in-grub_xnu_devprop_add_property.patch | 53 - ...sure-we-don-t-dereference-past-array.patch | 49 - 0235-term-Fix-overflow-on-user-inputs.patch | 63 - 0236-udf-Fix-memory-leak.patch | 53 - ...emory-leak-if-grub_create_loader_cmd.patch | 32 - 0238-tftp-Do-not-use-priority-queue.patch | 278 - ...in-address-for-mbi-allocation-to-0x1.patch | 44 - ...t-grub_relocator_alloc_chunk_addr-in.patch | 147 - ...t-grub_relocator_alloc_chunk_align-m.patch | 335 - ...used-fields-from-grub_script_functio.patch | 30 - ...se-after-free-when-redefining-a-func.patch | 105 - ...ub_relocator_alloc_chunk_align-top-m.patch | 43 - 0245-hfsplus-fix-two-more-overflows.patch | 54 - ...-potential-data-dependent-alloc-over.patch | 108 - 0247-emu-make-grub_free-NULL-safe.patch | 31 - ...formed-device-path-arithmetic-errors.patch | 248 - ...-caused-by-efi-fix-some-malformed-de.patch | 84 - ...x-use-after-free-in-halt-reboot-path.patch | 162 - ...x-use-after-free-in-halt-reboot-path.patch | 57 - ...id-overflow-on-initrd-size-calculati.patch | 25 - ...er-overflows-in-initrd-size-handling.patch | 166 - ...ointers-in-grub-core-commands-blscfg.patch | 43 - ...char-pointers-in-grub-core-net-url.c.patch | 28 - ...lock-counter-to-prevent-timeouts-wit.patch | 51 - ...dd-support-for-new-RAID1C34-profiles.patch | 51 - ...lling-uninitialized-function-pointer.patch | 41 - ...-install-is-no-longer-a-shell-script.patch | 33 - ...key-has-been-supported-for-some-time.patch | 36 - ...verifiers-provide-unsafe-module-list.patch | 97 - ...pended-signature-enforcement-to-ibm-.patch | 137 - ...k-if-petitboot-sysfs-has-a-valid-ver.patch | 67 - bootstrap.conf | 12 +- gitignore | 468 +- grub.macros | 8 +- grub.patches | 480 +- grub2.spec | 19 +- sbat.csv.in | 3 + sources | 4 +- 315 files changed, 2750 insertions(+), 24936 deletions(-) delete mode 100644 0011-Honor-a-symlink-when-generating-configuration-by-gru.patch rename 0012-Move-bash-completion-script-922997.patch => 0011-Move-bash-completion-script-922997.patch (92%) rename 0014-Allow-fallback-to-include-entries-by-title-not-just-.patch => 0012-Allow-fallback-to-include-entries-by-title-not-just-.patch (90%) rename 0016-Make-exit-take-a-return-code.patch => 0013-Make-exit-take-a-return-code.patch (93%) delete mode 100644 0013-Update-to-minilzo-2.08.patch rename 0018-Make-efi-machines-load-an-env-block-from-a-variable.patch => 0014-Make-efi-machines-load-an-env-block-from-a-variable.patch (74%) delete mode 100644 0015-Add-GRUB_DISABLE_UUID.patch rename 0022-Migrate-PPC-from-Yaboot-to-Grub2.patch => 0015-Migrate-PPC-from-Yaboot-to-Grub2.patch (98%) rename 0023-Add-fw_path-variable-revised.patch => 0016-Add-fw_path-variable-revised.patch (91%) delete mode 100644 0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch rename 0024-Pass-x-hex-hex-straight-through-unmolested.patch => 0017-Pass-x-hex-hex-straight-through-unmolested.patch (86%) rename 0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch => 0018-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch (91%) rename 0028-Add-devicetree-loading.patch => 0019-Add-devicetree-loading.patch (94%) delete mode 100644 0019-DHCP-client-ID-and-UUID-options-added.patch rename 0029-Don-t-write-messages-to-the-screen.patch => 0020-Don-t-write-messages-to-the-screen.patch (89%) delete mode 100644 0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch delete mode 100644 0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch rename 0030-Don-t-print-GNU-GRUB-header.patch => 0021-Don-t-print-GNU-GRUB-header.patch (96%) rename 0031-Don-t-add-to-highlighted-row.patch => 0022-Don-t-add-to-highlighted-row.patch (95%) rename 0032-Message-string-cleanups.patch => 0023-Message-string-cleanups.patch (98%) rename 0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch => 0024-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch (96%) delete mode 100644 0025-Add-X-option-to-printf-functions.patch rename 0034-Use-the-correct-indentation-for-the-term-help-text.patch => 0025-Use-the-correct-indentation-for-the-term-help-text.patch (90%) rename 0035-Indent-menu-entries.patch => 0026-Indent-menu-entries.patch (95%) delete mode 100644 0026-Search-for-specific-config-file-for-netboot.patch rename 0036-Fix-margins.patch => 0027-Fix-margins.patch (97%) rename 0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch => 0028-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch (95%) rename 0038-Enable-pager-by-default.-985860.patch => 0029-Enable-pager-by-default.-985860.patch (100%) rename 0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch => 0030-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch (96%) rename 0040-Don-t-say-GNU-Linux-in-generated-menus.patch => 0031-Don-t-say-GNU-Linux-in-generated-menus.patch (95%) rename 0041-Don-t-draw-a-border-around-the-menu.patch => 0032-Don-t-draw-a-border-around-the-menu.patch (98%) rename 0042-Use-the-standard-margin-for-the-timeout-string.patch => 0033-Use-the-standard-margin-for-the-timeout-string.patch (97%) rename 0043-Add-.eh_frame-to-list-of-relocations-stripped.patch => 0034-Add-.eh_frame-to-list-of-relocations-stripped.patch (96%) rename 0045-Don-t-require-a-password-to-boot-entries-generated-b.patch => 0035-Don-t-require-a-password-to-boot-entries-generated-b.patch (96%) rename 0046-Don-t-emit-Booting-.-message.patch => 0036-Don-t-emit-Booting-.-message.patch (87%) rename 0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch => 0037-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch (99%) rename 0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch => 0038-use-fw_path-prefix-when-fallback-searching-for-grub-.patch (97%) rename 0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch => 0039-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch (77%) rename 0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch => 0040-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch (96%) rename 0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch => 0041-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch (93%) rename 0055-Try-prefix-if-fw_path-doesn-t-work.patch => 0042-Try-prefix-if-fw_path-doesn-t-work.patch (85%) rename 0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch => 0043-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch (93%) delete mode 100644 0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch rename 0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch => 0044-Make-grub2-mkconfig-construct-titles-that-look-like-.patch (98%) rename 0060-Add-friendly-grub2-password-config-tool-985962.patch => 0045-Add-friendly-grub2-password-config-tool-985962.patch (96%) rename 0061-tcp-add-window-scaling-support.patch => 0046-tcp-add-window-scaling-support.patch (100%) rename 0064-efinet-and-bootp-add-support-for-dhcpv6.patch => 0047-efinet-and-bootp-add-support-for-dhcpv6.patch (92%) rename 0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch => 0048-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch (94%) rename 0067-bz1374141-fix-incorrect-mask-for-ppc64.patch => 0049-bz1374141-fix-incorrect-mask-for-ppc64.patch (100%) delete mode 100644 0050-Fix-convert-function-to-support-NVMe-devices.patch rename 0068-Make-grub_fatal-also-backtrace.patch => 0050-Make-grub_fatal-also-backtrace.patch (95%) delete mode 100644 0051-Add-grub_util_readlink.patch rename 0069-Fix-up-some-man-pages-rpmdiff-noticed.patch => 0051-Fix-up-some-man-pages-rpmdiff-noticed.patch (96%) delete mode 100644 0052-Make-editenv-chase-symlinks-including-those-across-d.patch rename 0071-Make-our-info-pages-say-grub2-where-appropriate.patch => 0052-Make-our-info-pages-say-grub2-where-appropriate.patch (88%) rename 0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch => 0053-macos-just-build-chainloader-entries-don-t-try-any-x.patch (97%) rename 0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch => 0054-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch (95%) rename 0075-export-btrfs_subvol-and-btrfs_subvolid.patch => 0055-export-btrfs_subvol-and-btrfs_subvolid.patch (91%) delete mode 100644 0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch rename 0076-grub2-btrfs-03-follow_default.patch => 0056-grub2-btrfs-03-follow_default.patch (89%) rename 0077-grub2-btrfs-04-grub2-install.patch => 0057-grub2-btrfs-04-grub2-install.patch (94%) delete mode 100644 0058-Handle-rssd-storage-devices.patch rename 0078-grub2-btrfs-05-grub2-mkconfig.patch => 0058-grub2-btrfs-05-grub2-mkconfig.patch (95%) rename 0079-grub2-btrfs-06-subvol-mount.patch => 0059-grub2-btrfs-06-subvol-mount.patch (95%) rename 0080-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch => 0060-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch (94%) rename 0081-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch => 0061-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch (97%) rename 0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch => 0062-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch (96%) delete mode 100644 0062-Fix-security-issue-when-reading-username-and-passwor.patch delete mode 100644 0063-Add-a-url-parser.patch rename 0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch => 0063-Use-grub_efi_.-memory-helpers-where-reasonable.patch (89%) rename 0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch => 0064-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch (78%) rename 0087-don-t-use-int-for-efi-status.patch => 0065-don-t-use-int-for-efi-status.patch (88%) delete mode 100644 0066-Normalize-slashes-in-tftp-paths.patch rename 0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch => 0066-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch (96%) rename 0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch => 0067-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch (92%) rename 0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch => 0068-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch (51%) rename 0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch => 0069-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch (100%) rename 0094-align-struct-efi_variable-better.patch => 0070-align-struct-efi_variable-better.patch (96%) delete mode 100644 0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch create mode 100644 0071-Add-BLS-support-to-grub-mkconfig.patch rename 0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch => 0072-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch (89%) delete mode 100644 0072-print-more-debug-info-in-our-module-loader.patch rename 0097-Add-linux-and-initrd-commands-for-grub-emu.patch => 0073-Add-linux-and-initrd-commands-for-grub-emu.patch (96%) rename 0098-Add-grub2-switch-to-blscfg.patch => 0074-Add-grub2-switch-to-blscfg.patch (87%) rename 0100-make-better-backtraces.patch => 0075-make-better-backtraces.patch (96%) rename 0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch => 0076-normal-don-t-draw-our-startup-message-if-debug-is-se.patch (89%) rename 0102-Work-around-some-minor-include-path-weirdnesses.patch => 0077-Work-around-some-minor-include-path-weirdnesses.patch (100%) rename 0103-Make-it-possible-to-enabled-build-id-sha1.patch => 0078-Make-it-possible-to-enabled-build-id-sha1.patch (93%) rename 0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch => 0079-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch (89%) rename 0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch => 0080-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch (90%) rename 0106-Fixup-for-newer-compiler.patch => 0081-Fixup-for-newer-compiler.patch (92%) rename 0107-Don-t-attempt-to-export-the-start-and-_start-symbols.patch => 0082-Don-t-attempt-to-export-the-start-and-_start-symbols.patch (94%) rename 0108-Fixup-for-newer-compiler.patch => 0083-Fixup-for-newer-compiler.patch (96%) rename 0109-Add-support-for-non-Ethernet-network-cards.patch => 0084-Add-support-for-non-Ethernet-network-cards.patch (97%) delete mode 100644 0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch rename 0111-net-read-bracketed-ipv6-addrs-and-port-numbers.patch => 0085-net-read-bracketed-ipv6-addrs-and-port-numbers.patch (87%) rename 0112-bootp-New-net_bootp6-command.patch => 0086-bootp-New-net_bootp6-command.patch (98%) delete mode 100644 0086-don-t-ignore-const.patch rename 0113-efinet-UEFI-IPv6-PXE-support.patch => 0087-efinet-UEFI-IPv6-PXE-support.patch (92%) rename 0114-grub.texi-Add-net_bootp6-doument.patch => 0088-grub.texi-Add-net_bootp6-doument.patch (80%) rename 0115-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch => 0089-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch (88%) delete mode 100644 0089-editenv-handle-relative-symlinks.patch delete mode 100644 0090-Make-libgrub.pp-depend-on-config-util.h.patch rename 0116-efinet-Setting-network-from-UEFI-device-path.patch => 0090-efinet-Setting-network-from-UEFI-device-path.patch (95%) rename 0117-efinet-Setting-DNS-server-from-UEFI-protocol.patch => 0091-efinet-Setting-DNS-server-from-UEFI-protocol.patch (92%) rename 0119-Support-UEFI-networking-protocols.patch => 0092-Support-UEFI-networking-protocols.patch (99%) rename 0120-AUDIT-0-http-boot-tracker-bug.patch => 0093-AUDIT-0-http-boot-tracker-bug.patch (98%) rename 0128-grub-editenv-Add-incr-command-to-increment-integer-v.patch => 0094-grub-editenv-Add-incr-command-to-increment-integer-v.patch (94%) delete mode 100644 0095-Add-BLS-support-to-grub-mkconfig.patch rename 0129-Add-auto-hide-menu-support.patch => 0095-Add-auto-hide-menu-support.patch (94%) rename 0131-Add-grub-set-bootflag-utility.patch => 0096-Add-grub-set-bootflag-utility.patch (97%) rename 0132-docs-Add-grub-boot-indeterminate.service-example.patch => 0097-docs-Add-grub-boot-indeterminate.service-example.patch (100%) rename 0133-gentpl-add-disable-support.patch => 0098-gentpl-add-disable-support.patch (97%) delete mode 100644 0099-Add-grub_debug_enabled.patch rename 0134-gentpl-add-pc-firmware-type.patch => 0099-gentpl-add-pc-firmware-type.patch (95%) rename 0135-efinet-also-use-the-firmware-acceleration-for-http.patch => 0100-efinet-also-use-the-firmware-acceleration-for-http.patch (100%) rename 0136-efi-http-Make-root_url-reflect-the-protocol-hostname.patch => 0101-efi-http-Make-root_url-reflect-the-protocol-hostname.patch (100%) rename 0137-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch => 0102-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch (96%) rename 0138-module-verifier-make-it-possible-to-run-checkers-on-.patch => 0103-module-verifier-make-it-possible-to-run-checkers-on-.patch (100%) rename 0139-Rework-how-the-fdt-command-builds.patch => 0104-Rework-how-the-fdt-command-builds.patch (92%) rename 0140-Disable-non-wordsize-allocations-on-arm.patch => 0105-Disable-non-wordsize-allocations-on-arm.patch (93%) rename 0142-Prepend-prefix-when-HTTP-path-is-relative.patch => 0106-Prepend-prefix-when-HTTP-path-is-relative.patch (98%) rename 0144-Make-grub_error-more-verbose.patch => 0107-Make-grub_error-more-verbose.patch (51%) rename 0145-Make-reset-an-alias-for-the-reboot-command.patch => 0108-Make-reset-an-alias-for-the-reboot-command.patch (100%) rename 0147-Add-a-version-command.patch => 0109-Add-a-version-command.patch (96%) rename 0148-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch => 0110-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch (91%) delete mode 100644 0110-misc-fix-invalid-character-recongition-in-strto-l.patch rename 0149-arm-arm64-loader-Better-memory-allocation-and-error-.patch => 0111-arm-arm64-loader-Better-memory-allocation-and-error-.patch (89%) rename 0150-Try-to-pick-better-locations-for-kernel-and-initrd.patch => 0112-Try-to-pick-better-locations-for-kernel-and-initrd.patch (97%) rename 0151-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch => 0113-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch (93%) rename 0152-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch => 0114-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch (92%) rename 0153-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch => 0115-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch (100%) rename 0154-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch => 0116-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch (100%) rename 0155-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch => 0117-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch (98%) delete mode 100644 0118-Fix-one-more-coverity-complaint.patch rename 0156-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch => 0118-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch (98%) rename 0157-Fix-getroot.c-s-trampolines.patch => 0119-Fix-getroot.c-s-trampolines.patch (97%) rename 0158-Do-not-allow-stack-trampolines-anywhere.patch => 0120-Do-not-allow-stack-trampolines-anywhere.patch (90%) rename 0159-Reimplement-boot_counter.patch => 0121-Reimplement-boot_counter.patch (97%) delete mode 100644 0121-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch rename 0161-Fix-menu-entry-selection-based-on-ID-and-title.patch => 0122-Fix-menu-entry-selection-based-on-ID-and-title.patch (100%) delete mode 100644 0122-efi-uga-use-64-bit-for-fb_base.patch delete mode 100644 0123-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch rename 0162-Make-the-menu-entry-users-option-argument-to-be-opti.patch => 0123-Make-the-menu-entry-users-option-argument-to-be-opti.patch (97%) rename 0163-Add-efi-export-env-and-efi-load-env-commands.patch => 0124-Add-efi-export-env-and-efi-load-env-commands.patch (91%) delete mode 100644 0124-EFI-console-Add-grub_console_read_key_stroke-helper-.patch delete mode 100644 0125-EFI-console-Implement-getkeystatus-support.patch rename 0164-Make-it-possible-to-subtract-conditions-from-debug.patch => 0125-Make-it-possible-to-subtract-conditions-from-debug.patch (95%) rename 0165-Export-all-variables-from-the-initial-context-when-c.patch => 0126-Export-all-variables-from-the-initial-context-when-c.patch (100%) delete mode 100644 0126-Make-grub_getkeystatus-helper-funtion-available-ever.patch delete mode 100644 0127-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch rename 0170-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch => 0127-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch (98%) rename 0171-Fix-systemctl-kexec-exit-status-check.patch => 0128-Fix-systemctl-kexec-exit-status-check.patch (100%) rename 0172-Print-grub-emu-linux-loader-messages-as-debug.patch => 0129-Print-grub-emu-linux-loader-messages-as-debug.patch (100%) rename 0173-Don-t-assume-that-boot-commands-will-only-return-on-.patch => 0130-Don-t-assume-that-boot-commands-will-only-return-on-.patch (80%) delete mode 100644 0130-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch rename 0174-Fix-undefined-references-for-fdt-when-building-with-.patch => 0131-Fix-undefined-references-for-fdt-when-building-with-.patch (100%) rename 0175-Do-better-in-bootstrap.conf.patch => 0132-Do-better-in-bootstrap.conf.patch (95%) rename 0176-Use-git-to-apply-gnulib-patches.patch => 0133-Use-git-to-apply-gnulib-patches.patch (70%) rename 0179-Fix-build-error-with-the-fdt-module-on-risc-v.patch => 0134-Fix-build-error-with-the-fdt-module-on-risc-v.patch (100%) rename 0186-grub-set-bootflag-Update-comment-about-running-as-ro.patch => 0135-grub-set-bootflag-Update-comment-about-running-as-ro.patch (100%) rename 0187-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch => 0136-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch (100%) rename 0189-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch => 0137-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch (100%) rename 0192-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch => 0138-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch (100%) rename 0193-chainloader-Define-machine-types-for-RISC-V.patch => 0139-chainloader-Define-machine-types-for-RISC-V.patch (91%) rename 0194-Add-start-symbol-for-RISC-V.patch => 0140-Add-start-symbol-for-RISC-V.patch (100%) rename 0198-bootstrap.conf-Force-autogen.sh-to-use-python3.patch => 0141-bootstrap.conf-Force-autogen.sh-to-use-python3.patch (86%) delete mode 100644 0141-strip-R-.note.gnu.property-at-more-places.patch rename 0199-efi-http-Export-fw-http-_path-variables-to-make-them.patch => 0142-efi-http-Export-fw-http-_path-variables-to-make-them.patch (95%) delete mode 100644 0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch rename 0200-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch => 0143-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch (100%) rename 0201-efi-net-Allow-to-specify-a-port-number-in-addresses.patch => 0144-efi-net-Allow-to-specify-a-port-number-in-addresses.patch (100%) rename 0202-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch => 0145-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch (100%) delete mode 100644 0146-EFI-more-debug-output-on-GOP-and-UGA-probing.patch rename 0203-efi-net-Print-a-debug-message-if-parsing-the-address.patch => 0146-efi-net-Print-a-debug-message-if-parsing-the-address.patch (100%) create mode 100644 0147-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch rename 0210-efi-Set-image-base-address-before-jumping-to-the-PE-.patch => 0148-efi-Set-image-base-address-before-jumping-to-the-PE-.patch (82%) rename 0216-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch => 0149-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch (90%) rename 0219-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch => 0150-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch (97%) rename 0220-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch => 0151-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch (80%) rename 0224-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch => 0152-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch (95%) rename 0251-efi-dhcp-fix-some-allocation-error-checking.patch => 0153-efi-dhcp-fix-some-allocation-error-checking.patch (100%) rename 0252-efi-http-fix-some-allocation-error-checking.patch => 0154-efi-http-fix-some-allocation-error-checking.patch (100%) rename 0253-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch => 0155-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch (100%) rename 0254-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch => 0156-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch (97%) rename 0257-linuxefi-fail-kernel-validation-without-shim-protoco.patch => 0157-linuxefi-fail-kernel-validation-without-shim-protoco.patch (90%) rename 0260-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch => 0158-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch (88%) rename 0261-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch => 0159-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch (100%) rename 0262-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch => 0160-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch (100%) delete mode 100644 0160-Make-grub_strtol-end-pointers-have-safer-const-quali.patch rename 0263-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch => 0161-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch (100%) rename 0264-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch => 0162-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch (100%) rename 0266-Add-systemd-integration-scripts-to-make-systemctl-re.patch => 0163-Add-systemd-integration-scripts-to-make-systemctl-re.patch (97%) rename 0267-systemd-integration.sh-Also-set-old-menu_show_once-g.patch => 0164-systemd-integration.sh-Also-set-old-menu_show_once-g.patch (100%) rename 0302-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch => 0165-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch (99%) delete mode 100644 0166-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch rename 0269-grub-install-disable-support-for-EFI-platforms.patch => 0166-grub-install-disable-support-for-EFI-platforms.patch (96%) rename 0270-New-with-debug-timestamps-configure-flag-to-prepend-.patch => 0167-New-with-debug-timestamps-configure-flag-to-prepend-.patch (92%) delete mode 100644 0167-Try-to-set-fPIE-and-friends-on-libgnu.a.patch rename 0271-Added-debug-statements-to-grub_disk_open-and-grub_di.patch => 0168-Added-debug-statements-to-grub_disk_open-and-grub_di.patch (97%) delete mode 100644 0168-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch delete mode 100644 0169-Fix-the-type-of-grub_efi_status_t.patch rename 0272-Introduce-function-grub_debug_is_enabled-void-return.patch => 0169-Introduce-function-grub_debug_is_enabled-void-return.patch (87%) rename 0273-Don-t-clear-screen-when-debugging-is-enabled.patch => 0170-Don-t-clear-screen-when-debugging-is-enabled.patch (95%) rename 0274-grub_file_-instrumentation-new-file-debug-tag.patch => 0171-grub_file_-instrumentation-new-file-debug-tag.patch (100%) rename 0275-ieee1275-Avoiding-many-unecessary-open-close.patch => 0172-ieee1275-Avoiding-many-unecessary-open-close.patch (100%) rename 0276-ieee1275-powerpc-implements-fibre-channel-discovery-.patch => 0173-ieee1275-powerpc-implements-fibre-channel-discovery-.patch (100%) rename 0277-ieee1275-powerpc-enables-device-mapper-discovery.patch => 0174-ieee1275-powerpc-enables-device-mapper-discovery.patch (100%) rename 0303-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch => 0175-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch (99%) rename 0280-Add-suport-for-signing-grub-with-an-appended-signatu.patch => 0176-Add-suport-for-signing-grub-with-an-appended-signatu.patch (77%) delete mode 100644 0177-autogen.sh-use-find-wholename-for-long-path-matches.patch rename 0281-docs-grub-Document-signing-grub-under-UEFI.patch => 0177-docs-grub-Document-signing-grub-under-UEFI.patch (60%) delete mode 100644 0178-bootstrap.conf-don-t-clobber-AM_CFLAGS-here.patch rename 0282-docs-grub-Document-signing-grub-with-an-appended-sig.patch => 0178-docs-grub-Document-signing-grub-with-an-appended-sig.patch (76%) rename 0285-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch => 0179-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch (92%) delete mode 100644 0180-RISC-V-Fix-computation-of-pc-relative-relocation-off.patch rename 0287-pgp-factor-out-rsa_pad.patch => 0180-pgp-factor-out-rsa_pad.patch (98%) delete mode 100644 0181-blscfg-Add-support-for-the-devicetree-field.patch rename 0288-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch => 0181-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch (96%) delete mode 100644 0182-Set-a-devicetree-var-in-a-BLS-config-if-GRUB_DEFAULT.patch rename 0289-posix_wrap-tweaks-in-preparation-for-libtasn1.patch => 0182-posix_wrap-tweaks-in-preparation-for-libtasn1.patch (100%) delete mode 100644 0183-Don-t-add-a-class-option-to-menu-entries-generated-f.patch rename 0290-libtasn1-import-libtasn1-4.16.0.patch => 0183-libtasn1-import-libtasn1-4.16.0.patch (100%) delete mode 100644 0184-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch rename 0291-libtasn1-disable-code-not-needed-in-grub.patch => 0184-libtasn1-disable-code-not-needed-in-grub.patch (100%) delete mode 100644 0185-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch rename 0292-libtasn1-changes-for-grub-compatibility.patch => 0185-libtasn1-changes-for-grub-compatibility.patch (100%) rename 0293-libtasn1-compile-into-asn1-module.patch => 0186-libtasn1-compile-into-asn1-module.patch (97%) rename 0294-test_asn1-test-module-for-libtasn1.patch => 0187-test_asn1-test-module-for-libtasn1.patch (99%) delete mode 100644 0188-blscfg-add-a-space-char-when-appending-fields-for-va.patch rename 0295-grub-install-support-embedding-x509-certificates.patch => 0188-grub-install-support-embedding-x509-certificates.patch (77%) rename 0296-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch => 0189-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch (100%) rename 0297-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch => 0190-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch (97%) delete mode 100644 0190-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch delete mode 100644 0191-Fix-savedefault-with-blscfg.patch rename 0298-appended-signatures-support-verifying-appended-signa.patch => 0191-appended-signatures-support-verifying-appended-signa.patch (88%) rename 0299-appended-signatures-verification-tests.patch => 0192-appended-signatures-verification-tests.patch (86%) rename 0300-appended-signatures-documentation.patch => 0193-appended-signatures-documentation.patch (76%) create mode 100644 0194-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch delete mode 100644 0195-RISC-V-Add-__clzdi2-symbol.patch create mode 100644 0195-Revert-templates-Properly-disable-the-os-prober-by-d.patch create mode 100644 0196-Revert-templates-Disable-the-os-prober-by-default.patch delete mode 100644 0196-grub-install-Define-default-platform-for-RISC-V.patch delete mode 100644 0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch delete mode 100644 0204-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch delete mode 100644 0205-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch delete mode 100644 0206-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch delete mode 100644 0207-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch delete mode 100644 0208-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch delete mode 100644 0209-10_linux.in-Enable-BLS-configuration-if-new-kernel-p.patch delete mode 100644 0211-blscfg-Lookup-default_kernelopts-variable-as-fallbac.patch delete mode 100644 0212-10_linux.in-fix-early-exit-due-error-when-reading-pe.patch delete mode 100644 0213-envblk-Fix-buffer-overrun-when-attempting-to-shrink-.patch delete mode 100644 0214-10_linux.in-Store-cmdline-in-BLS-snippets-instead-of.patch delete mode 100644 0215-10_linux.in-restore-existence-check-in-get_sorted_bl.patch delete mode 100644 0217-tpm-Enable-module-for-all-EFI-platforms.patch delete mode 100644 0218-10_linux.in-Don-t-update-BLS-files-that-aren-t-manag.patch delete mode 100644 0221-fix-build-with-rpm-4.16.patch delete mode 100644 0222-Only-mark-GRUB-as-BLS-supported-in-OSTree-systems-wi.patch delete mode 100644 0223-Don-t-assume-that-boot-commands-will-only-return-on-.patch delete mode 100644 0225-yylex-Make-lexer-fatal-errors-actually-be-fatal.patch delete mode 100644 0226-safemath-Add-some-arithmetic-primitives-that-check-f.patch delete mode 100644 0227-calloc-Make-sure-we-always-have-an-overflow-checking.patch delete mode 100644 0228-calloc-Use-calloc-at-most-places.patch delete mode 100644 0229-malloc-Use-overflow-checking-primitives-where-we-do-.patch delete mode 100644 0230-iso9660-Don-t-leak-memory-on-realloc-failures.patch delete mode 100644 0231-font-Do-not-load-more-than-one-NAME-section.patch delete mode 100644 0232-gfxmenu-Fix-double-free-in-load_image.patch delete mode 100644 0233-xnu-Fix-double-free-in-grub_xnu_devprop_add_property.patch delete mode 100644 0234-lzma-Make-sure-we-don-t-dereference-past-array.patch delete mode 100644 0235-term-Fix-overflow-on-user-inputs.patch delete mode 100644 0236-udf-Fix-memory-leak.patch delete mode 100644 0237-multiboot2-Fix-memory-leak-if-grub_create_loader_cmd.patch delete mode 100644 0238-tftp-Do-not-use-priority-queue.patch delete mode 100644 0239-multiboot2-Set-min-address-for-mbi-allocation-to-0x1.patch delete mode 100644 0240-relocator-Protect-grub_relocator_alloc_chunk_addr-in.patch delete mode 100644 0241-relocator-Protect-grub_relocator_alloc_chunk_align-m.patch delete mode 100644 0242-script-Remove-unused-fields-from-grub_script_functio.patch delete mode 100644 0243-script-Avoid-a-use-after-free-when-redefining-a-func.patch delete mode 100644 0244-relocator-Fix-grub_relocator_alloc_chunk_align-top-m.patch delete mode 100644 0245-hfsplus-fix-two-more-overflows.patch delete mode 100644 0246-lvm-fix-two-more-potential-data-dependent-alloc-over.patch delete mode 100644 0247-emu-make-grub_free-NULL-safe.patch delete mode 100644 0248-efi-fix-some-malformed-device-path-arithmetic-errors.patch delete mode 100644 0249-Fix-a-regression-caused-by-efi-fix-some-malformed-de.patch delete mode 100644 0250-efi-Fix-use-after-free-in-halt-reboot-path.patch delete mode 100644 0255-efi-Fix-use-after-free-in-halt-reboot-path.patch delete mode 100644 0256-linux-loader-avoid-overflow-on-initrd-size-calculati.patch delete mode 100644 0258-linux-Fix-integer-overflows-in-initrd-size-handling.patch delete mode 100644 0259-Fix-const-char-pointers-in-grub-core-commands-blscfg.patch delete mode 100644 0265-Fix-const-char-pointers-in-grub-core-net-url.c.patch delete mode 100644 0268-tftp-roll-over-block-counter-to-prevent-timeouts-wit.patch delete mode 100644 0278-btrfs-Add-support-for-new-RAID1C34-profiles.patch delete mode 100644 0279-verifiers-Fix-calling-uninitialized-function-pointer.patch delete mode 100644 0283-docs-grub-grub-install-is-no-longer-a-shell-script.patch delete mode 100644 0284-docs-grub-pubkey-has-been-supported-for-some-time.patch delete mode 100644 0286-verifiers-provide-unsafe-module-list.patch delete mode 100644 0301-ieee1275-link-appended-signature-enforcement-to-ibm-.patch delete mode 100644 0304-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch create mode 100755 sbat.csv.in diff --git a/0001-Add-support-for-Linux-EFI-stub-loading.patch b/0001-Add-support-for-Linux-EFI-stub-loading.patch index 95c7cd5..74044b8 100644 --- a/0001-Add-support-for-Linux-EFI-stub-loading.patch +++ b/0001-Add-support-for-Linux-EFI-stub-loading.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Matthew Garrett -Date: Fri, 5 Jul 2019 18:36:44 +0200 +Date: Tue, 10 Jul 2012 11:58:52 -0400 Subject: [PATCH] Add support for Linux EFI stub loading. Also: @@ -35,19 +35,19 @@ moves the check into grub_dl_load_file. grub-core/loader/i386/efi/linux.c | 335 ++++++++++++++++++++++++++++++++++++++ grub-core/loader/i386/pc/linux.c | 10 +- include/grub/arm/linux.h | 9 + - include/grub/arm64/linux.h | 10 ++ + include/grub/arm64/linux.h | 9 + include/grub/efi/efi.h | 7 +- include/grub/efi/linux.h | 31 ++++ - 13 files changed, 619 insertions(+), 69 deletions(-) + 13 files changed, 618 insertions(+), 69 deletions(-) create mode 100644 grub-core/loader/efi/linux.c create mode 100644 grub-core/loader/i386/efi/linux.c create mode 100644 include/grub/efi/linux.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 474a63e68c5..581d9dfc3b3 100644 +index 8022e1c0a79..45d3edaa4dc 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -1709,13 +1709,6 @@ module = { +@@ -1734,13 +1734,6 @@ module = { enable = i386_pc; }; @@ -61,7 +61,7 @@ index 474a63e68c5..581d9dfc3b3 100644 module = { name = ntldr; i386_pc = loader/i386/pc/ntldr.c; -@@ -1771,7 +1764,9 @@ module = { +@@ -1796,7 +1789,9 @@ module = { module = { name = linux; @@ -72,7 +72,7 @@ index 474a63e68c5..581d9dfc3b3 100644 i386_xen_pvh = loader/i386/linux.c; xen = loader/i386/xen.c; i386_pc = lib/i386/pc/vesa_modes_table.c; -@@ -1786,9 +1781,14 @@ module = { +@@ -1811,9 +1806,14 @@ module = { arm64 = loader/arm64/linux.c; riscv32 = loader/riscv/linux.c; riscv64 = loader/riscv/linux.c; @@ -88,7 +88,7 @@ index 474a63e68c5..581d9dfc3b3 100644 module = { diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 48eb5e7b627..896bebfd57e 100644 +index 48f8a79073d..b7149370950 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -38,6 +38,14 @@ @@ -106,7 +106,7 @@ index 48eb5e7b627..896bebfd57e 100644 #pragma GCC diagnostic ignored "-Wcast-align" -@@ -686,6 +694,19 @@ grub_dl_load_file (const char *filename) +@@ -695,6 +703,19 @@ grub_dl_load_file (const char *filename) void *core = 0; grub_dl_t mod = 0; @@ -127,11 +127,11 @@ index 48eb5e7b627..896bebfd57e 100644 file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE); diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 6e1ceb90516..a0faa40ecf0 100644 +index 8cff7be0289..35b8f670602 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -273,6 +273,34 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - return NULL; +@@ -286,6 +286,34 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, + return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL); } +grub_efi_boolean_t @@ -166,7 +166,7 @@ index 6e1ceb90516..a0faa40ecf0 100644 /* Search the mods section from the PE32/PE32+ image. This code uses diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index b02fab1b102..a9e37108c6d 100644 +index 0cdb063bb1b..74360542062 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -113,6 +113,38 @@ grub_efi_drop_alloc (grub_efi_physical_address_t address, @@ -819,10 +819,10 @@ index 00000000000..bb2616a8092 + grub_unregister_command (cmd_initrdefi); +} diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 47ea2945e4f..eea25ea39ca 100644 +index 2a299520160..8be4c3b3f48 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c -@@ -470,14 +470,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), +@@ -474,14 +474,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } @@ -844,7 +844,7 @@ index 47ea2945e4f..eea25ea39ca 100644 grub_register_command ("initrd16", grub_cmd_initrd, 0, N_("Load initrd.")); my_mod = mod; -@@ -486,5 +492,7 @@ GRUB_MOD_INIT(linux16) +@@ -490,5 +496,7 @@ GRUB_MOD_INIT(linux16) GRUB_MOD_FINI(linux16) { grub_unregister_command (cmd_linux); @@ -853,7 +853,7 @@ index 47ea2945e4f..eea25ea39ca 100644 + grub_unregister_command (cmd_initrd16); } diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h -index 2e98a668969..775297db869 100644 +index bcd5a7eb186..b582f67f661 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -20,6 +20,7 @@ @@ -883,19 +883,18 @@ index 2e98a668969..775297db869 100644 #if defined GRUB_MACHINE_UBOOT diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h -index 4269adc6dae..a3be9dd7003 100644 +index 7e22b4ab699..ea030312df3 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h -@@ -19,6 +19,8 @@ +@@ -19,6 +19,7 @@ #ifndef GRUB_ARM64_LINUX_HEADER #define GRUB_ARM64_LINUX_HEADER 1 +#include -+ - #define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ + #include - /* From linux/Documentation/arm64/booting.txt */ -@@ -36,9 +38,17 @@ struct linux_arm64_kernel_header + #define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ +@@ -38,9 +39,17 @@ struct linux_arm64_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; @@ -914,7 +913,7 @@ index 4269adc6dae..a3be9dd7003 100644 #endif /* ! GRUB_ARM64_LINUX_HEADER */ diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index e90e00dc431..6840bfee9b7 100644 +index 83d958f9945..6295df85f3f 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -47,6 +47,9 @@ EXPORT_FUNC(grub_efi_allocate_fixed) (grub_efi_physical_address_t address, @@ -927,7 +926,7 @@ index e90e00dc431..6840bfee9b7 100644 void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void); -@@ -82,6 +85,7 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, +@@ -88,6 +91,7 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, const grub_efi_guid_t *guid, void *data, grub_size_t datasize); @@ -935,7 +934,7 @@ index e90e00dc431..6840bfee9b7 100644 int EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, const grub_efi_device_path_t *dp2); -@@ -95,8 +99,7 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); +@@ -101,8 +105,7 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); #include grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); diff --git a/0002-Rework-linux-command.patch b/0002-Rework-linux-command.patch index bd136d6..9954dd0 100644 --- a/0002-Rework-linux-command.patch +++ b/0002-Rework-linux-command.patch @@ -1,20 +1,22 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Matthew Garrett -Date: Fri, 5 Jul 2019 20:54:51 +0200 +Date: Sun, 9 Aug 2015 16:12:39 -0700 Subject: [PATCH] Rework linux command We want a single buffer that contains the entire kernel image in order to perform a TPM measurement. Allocate one and copy the entire kernel into it before pulling out the individual blocks later on. + +Signed-off-by: Matthew Garrett --- - grub-core/loader/i386/linux.c | 36 +++++++++++++++++++++++------------- - 1 file changed, 23 insertions(+), 13 deletions(-) + grub-core/loader/i386/linux.c | 35 +++++++++++++++++++++++------------ + 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index d0501e22957..b255c950526 100644 +index 9f74a96b19a..dccf3bb3005 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c -@@ -641,13 +641,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -649,13 +649,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file = 0; struct linux_i386_kernel_header lh; @@ -31,7 +33,7 @@ index d0501e22957..b255c950526 100644 grub_dl_ref (my_mod); -@@ -661,7 +663,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -669,7 +671,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (! file) goto fail; @@ -48,7 +50,7 @@ index d0501e22957..b255c950526 100644 { if (!grub_errno) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -669,6 +679,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -677,6 +687,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -58,32 +60,25 @@ index d0501e22957..b255c950526 100644 if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) { grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); -@@ -760,6 +773,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - preferred_address)) - goto fail; - -+ - grub_memset (&linux_params, 0, sizeof (linux_params)); - grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1); - -@@ -782,13 +796,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -784,13 +797,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* We've already read lh so there is no need to read it second time. */ len -= sizeof(lh); -- if (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len) -- { +- if ((len > 0) && +- (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len)) ++ linux_params_ptr = (void *)&linux_params; ++ if (len > 0) + { - if (!grub_errno) - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - argv[0]); - goto fail; -- } -+ linux_params_ptr = (void *)&linux_params; -+ grub_memcpy (linux_params_ptr + sizeof (lh), kernel + kernel_offset, len); -+ kernel_offset += len; ++ grub_memcpy (linux_params_ptr + sizeof (lh), kernel + kernel_offset, len); ++ kernel_offset += len; + } - linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE; - -@@ -847,7 +857,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + linux_params.code32_start = prot_mode_target + lh.code32_start - GRUB_LINUX_BZIMAGE_ADDR; +@@ -853,7 +864,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* The other parameters are filled when booting. */ @@ -92,7 +87,7 @@ index d0501e22957..b255c950526 100644 grub_dprintf ("linux", "bzImage, setup=0x%x, size=0x%x\n", (unsigned) real_size, (unsigned) prot_size); -@@ -1001,9 +1011,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -1007,9 +1018,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } len = prot_file_size; @@ -103,7 +98,7 @@ index d0501e22957..b255c950526 100644 if (grub_errno == GRUB_ERR_NONE) { -@@ -1014,6 +1022,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -1020,6 +1029,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), fail: diff --git a/0003-Rework-linux16-command.patch b/0003-Rework-linux16-command.patch index e73423b..2c2d6f0 100644 --- a/0003-Rework-linux16-command.patch +++ b/0003-Rework-linux16-command.patch @@ -1,20 +1,22 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Matthew Garrett -Date: Fri, 5 Jul 2019 21:12:00 +0200 +Date: Sun, 9 Aug 2015 16:20:58 -0700 Subject: [PATCH] Rework linux16 command We want a single buffer that contains the entire kernel image in order to perform a TPM measurement. Allocate one and copy the entire kernel int it before pulling out the individual blocks later on. + +Signed-off-by: Matthew Garrett --- grub-core/loader/i386/pc/linux.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index eea25ea39ca..73fb91e0570 100644 +index 8be4c3b3f48..4b1750e360e 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c -@@ -123,13 +123,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -124,13 +124,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_file_t file = 0; struct linux_i386_kernel_header lh; grub_uint8_t setup_sects; @@ -30,7 +32,7 @@ index eea25ea39ca..73fb91e0570 100644 grub_dl_ref (my_mod); -@@ -143,7 +144,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -144,7 +145,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (! file) goto fail; @@ -47,7 +49,7 @@ index eea25ea39ca..73fb91e0570 100644 { if (!grub_errno) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -151,6 +160,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -152,6 +161,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -57,7 +59,7 @@ index eea25ea39ca..73fb91e0570 100644 if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) { grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); -@@ -314,13 +326,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -320,13 +332,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_memmove (grub_linux_real_chunk, &lh, sizeof (lh)); len = real_size + GRUB_DISK_SECTOR_SIZE - sizeof (lh); @@ -74,7 +76,7 @@ index eea25ea39ca..73fb91e0570 100644 if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) -@@ -358,9 +366,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -364,9 +372,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } len = grub_linux16_prot_size; @@ -86,7 +88,7 @@ index eea25ea39ca..73fb91e0570 100644 if (grub_errno == GRUB_ERR_NONE) { -@@ -370,6 +377,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -376,6 +383,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), fail: diff --git a/0004-Add-secureboot-support-on-efi-chainloader.patch b/0004-Add-secureboot-support-on-efi-chainloader.patch index 092032b..bfb5a9b 100644 --- a/0004-Add-secureboot-support-on-efi-chainloader.patch +++ b/0004-Add-secureboot-support-on-efi-chainloader.patch @@ -167,18 +167,18 @@ Signed-off-by: Laszlo Ersek --- grub-core/kern/efi/efi.c | 14 +- grub-core/loader/arm64/linux.c | 4 +- - grub-core/loader/efi/chainloader.c | 817 +++++++++++++++++++++++++++++++++---- + grub-core/loader/efi/chainloader.c | 816 +++++++++++++++++++++++++++++++++---- grub-core/loader/efi/linux.c | 25 +- grub-core/loader/i386/efi/linux.c | 17 +- include/grub/efi/linux.h | 2 +- include/grub/efi/pe32.h | 52 ++- - 7 files changed, 840 insertions(+), 91 deletions(-) + 7 files changed, 840 insertions(+), 90 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index a0faa40ecf0..3487b0623a4 100644 +index 35b8f670602..4a2259aa1c7 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -283,14 +283,20 @@ grub_efi_secure_boot (void) +@@ -296,14 +296,20 @@ grub_efi_secure_boot (void) grub_efi_boolean_t ret = 0; secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); @@ -226,7 +226,7 @@ index a312c668685..04994d5c67d 100644 grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); goto fail; diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index cd92ea3f24b..ef87b06cf70 100644 +index 2bd80f4db3d..b54cf6986fc 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -32,6 +32,8 @@ @@ -261,15 +261,7 @@ index cd92ea3f24b..ef87b06cf70 100644 grub_dl_unref (my_mod); return GRUB_ERR_NONE; -@@ -179,7 +187,6 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) - /* Fill the file path for the directory. */ - d = (grub_efi_device_path_t *) ((char *) file_path - + ((char *) d - (char *) dp)); -- grub_efi_print_device_path (d); - copy_file_path ((grub_efi_file_path_device_path_t *) d, - dir_start, dir_end - dir_start); - -@@ -197,20 +204,690 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) +@@ -213,20 +221,690 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) return file_path; } @@ -963,7 +955,7 @@ index cd92ea3f24b..ef87b06cf70 100644 if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -222,15 +899,45 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -238,15 +916,45 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), address = 0; image_handle = 0; file_path = 0; @@ -1011,7 +1003,7 @@ index cd92ea3f24b..ef87b06cf70 100644 if (! dev) goto fail; -@@ -267,17 +974,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -283,17 +991,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), if (! file_path) goto fail; @@ -1032,7 +1024,7 @@ index cd92ea3f24b..ef87b06cf70 100644 status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES, GRUB_EFI_LOADER_CODE, -@@ -291,7 +995,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -307,7 +1012,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } boot_image = (void *) ((grub_addr_t) address); @@ -1041,7 +1033,7 @@ index cd92ea3f24b..ef87b06cf70 100644 { if (grub_errno == GRUB_ERR_NONE) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -301,7 +1005,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -317,7 +1022,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } #if defined (__i386__) || defined (__x86_64__) @@ -1050,12 +1042,12 @@ index cd92ea3f24b..ef87b06cf70 100644 { struct grub_macho_fat_header *head = boot_image; if (head->magic -@@ -310,6 +1014,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -326,6 +1031,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), grub_uint32_t i; struct grub_macho_fat_arch *archs = (struct grub_macho_fat_arch *) (head + 1); + -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + { + grub_error (GRUB_ERR_BAD_OS, + "MACHO binaries are forbidden with Secure Boot"); @@ -1065,7 +1057,7 @@ index cd92ea3f24b..ef87b06cf70 100644 for (i = 0; i < grub_cpu_to_le32 (head->nfat_arch); i++) { if (GRUB_MACHO_CPUTYPE_IS_HOST_CURRENT (archs[i].cputype)) -@@ -324,79 +1036,39 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -340,79 +1053,39 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), > ~grub_cpu_to_le32 (archs[i].size) || grub_cpu_to_le32 (archs[i].offset) + grub_cpu_to_le32 (archs[i].size) @@ -1162,7 +1154,7 @@ index cd92ea3f24b..ef87b06cf70 100644 if (dev) grub_device_close (dev); -@@ -408,6 +1080,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -424,6 +1097,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), if (address) efi_call_2 (b->free_pages, address, pages); diff --git a/0005-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch b/0005-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch index 382fd23..3182fe9 100644 --- a/0005-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch +++ b/0005-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch @@ -9,112 +9,94 @@ won't register commands if SB is enabled." Signed-off-by: Peter Jones --- - grub-core/Makefile.core.def | 1 + - grub-core/commands/iorw.c | 7 +++++ - grub-core/commands/memrw.c | 7 +++++ - grub-core/kern/dl.c | 1 + - grub-core/kern/efi/efi.c | 34 -------------------- - grub-core/kern/efi/sb.c | 64 ++++++++++++++++++++++++++++++++++++++ - grub-core/loader/efi/appleloader.c | 7 +++++ + grub-core/commands/iorw.c | 7 +++++++ + grub-core/commands/memrw.c | 7 +++++++ + grub-core/kern/dl.c | 3 ++- + grub-core/kern/efi/efi.c | 34 ---------------------------------- + grub-core/loader/efi/appleloader.c | 7 +++++++ grub-core/loader/efi/chainloader.c | 1 + - grub-core/loader/i386/bsd.c | 7 +++++ - grub-core/loader/i386/linux.c | 7 +++++ - grub-core/loader/i386/pc/linux.c | 7 +++++ - grub-core/loader/multiboot.c | 7 +++++ - grub-core/loader/xnu.c | 7 +++++ + grub-core/loader/i386/bsd.c | 7 +++++++ + grub-core/loader/i386/linux.c | 7 +++++++ + grub-core/loader/i386/pc/linux.c | 7 +++++++ + grub-core/loader/multiboot.c | 7 +++++++ + grub-core/loader/xnu.c | 7 +++++++ include/grub/efi/efi.h | 1 - - include/grub/efi/sb.h | 29 +++++++++++++++++ include/grub/ia64/linux.h | 0 include/grub/mips/linux.h | 0 include/grub/powerpc/linux.h | 0 include/grub/sparc64/linux.h | 0 - grub-core/Makefile.am | 1 + - 20 files changed, 153 insertions(+), 35 deletions(-) - create mode 100644 grub-core/kern/efi/sb.c - create mode 100644 include/grub/efi/sb.h + 16 files changed, 59 insertions(+), 36 deletions(-) create mode 100644 include/grub/ia64/linux.h create mode 100644 include/grub/mips/linux.h create mode 100644 include/grub/powerpc/linux.h create mode 100644 include/grub/sparc64/linux.h -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 581d9dfc3b3..eb1088fd654 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -207,6 +207,7 @@ kernel = { - i386_multiboot = kern/i386/pc/acpi.c; - i386_coreboot = kern/acpi.c; - i386_multiboot = kern/acpi.c; -+ common = kern/efi/sb.c; - - x86 = kern/i386/tsc.c; - x86 = kern/i386/tsc_pit.c; diff --git a/grub-core/commands/iorw.c b/grub-core/commands/iorw.c -index a0c164e54f0..41a7f3f0466 100644 +index 584baec8f91..7b2999b14b5 100644 --- a/grub-core/commands/iorw.c +++ b/grub-core/commands/iorw.c -@@ -23,6 +23,7 @@ - #include +@@ -24,6 +24,7 @@ #include #include + #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -@@ -118,6 +119,9 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) +@@ -119,6 +120,9 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) GRUB_MOD_INIT(memrw) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + cmd_read_byte = grub_register_extcmd ("inb", grub_cmd_read, 0, N_("PORT"), N_("Read 8-bit value from PORT."), -@@ -146,6 +150,9 @@ GRUB_MOD_INIT(memrw) +@@ -147,6 +151,9 @@ GRUB_MOD_INIT(memrw) GRUB_MOD_FINI(memrw) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + grub_unregister_extcmd (cmd_read_byte); grub_unregister_extcmd (cmd_read_word); grub_unregister_extcmd (cmd_read_dword); diff --git a/grub-core/commands/memrw.c b/grub-core/commands/memrw.c -index 98769eadb34..088cbe9e2bc 100644 +index d401a6db0ef..39cf3a06dbd 100644 --- a/grub-core/commands/memrw.c +++ b/grub-core/commands/memrw.c -@@ -22,6 +22,7 @@ - #include +@@ -23,6 +23,7 @@ #include #include + #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -@@ -120,6 +121,9 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) +@@ -121,6 +122,9 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) GRUB_MOD_INIT(memrw) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + cmd_read_byte = grub_register_extcmd ("read_byte", grub_cmd_read, 0, N_("ADDR"), N_("Read 8-bit value from ADDR."), -@@ -148,6 +152,9 @@ GRUB_MOD_INIT(memrw) +@@ -149,6 +153,9 @@ GRUB_MOD_INIT(memrw) GRUB_MOD_FINI(memrw) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + grub_unregister_extcmd (cmd_read_byte); grub_unregister_extcmd (cmd_read_word); grub_unregister_extcmd (cmd_read_dword); diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 896bebfd57e..d7718d26abc 100644 +index b7149370950..7afb9e6f724 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -32,6 +32,7 @@ @@ -125,12 +107,21 @@ index 896bebfd57e..d7718d26abc 100644 /* Platforms where modules are in a readonly area of memory. */ #if defined(GRUB_MACHINE_QEMU) +@@ -704,7 +705,7 @@ grub_dl_load_file (const char *filename) + grub_dl_t mod = 0; + + #ifdef GRUB_MACHINE_EFI +- if (grub_efi_secure_boot ()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + { + #if 0 + /* This is an error, but grub2-mkconfig still generates a pile of diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 3487b0623a4..6e1ceb90516 100644 +index 4a2259aa1c7..8cff7be0289 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -273,40 +273,6 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - return NULL; +@@ -286,40 +286,6 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, + return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL); } -grub_efi_boolean_t @@ -170,78 +161,8 @@ index 3487b0623a4..6e1ceb90516 100644 #pragma GCC diagnostic ignored "-Wcast-align" /* Search the mods section from the PE32/PE32+ image. This code uses -diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c -new file mode 100644 -index 00000000000..d74778b0cac ---- /dev/null -+++ b/grub-core/kern/efi/sb.c -@@ -0,0 +1,64 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2014 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+int -+grub_efi_secure_boot (void) -+{ -+#ifdef GRUB_MACHINE_EFI -+ grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; -+ grub_size_t datasize; -+ char *secure_boot = NULL; -+ char *setup_mode = NULL; -+ grub_efi_boolean_t ret = 0; -+ -+ secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); -+ if (datasize != 1 || !secure_boot) -+ { -+ grub_dprintf ("secureboot", "No SecureBoot variable\n"); -+ goto out; -+ } -+ grub_dprintf ("secureboot", "SecureBoot: %d\n", *secure_boot); -+ -+ setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); -+ if (datasize != 1 || !setup_mode) -+ { -+ grub_dprintf ("secureboot", "No SetupMode variable\n"); -+ goto out; -+ } -+ grub_dprintf ("secureboot", "SetupMode: %d\n", *setup_mode); -+ -+ if (*secure_boot && !*setup_mode) -+ ret = 1; -+ -+ out: -+ grub_free (secure_boot); -+ grub_free (setup_mode); -+ return ret; -+#else -+ return 0; -+#endif -+} diff --git a/grub-core/loader/efi/appleloader.c b/grub-core/loader/efi/appleloader.c -index 74888c463ba..69c2a10d351 100644 +index 74888c463ba..585f2b57385 100644 --- a/grub-core/loader/efi/appleloader.c +++ b/grub-core/loader/efi/appleloader.c @@ -24,6 +24,7 @@ @@ -256,7 +177,7 @@ index 74888c463ba..69c2a10d351 100644 GRUB_MOD_INIT(appleloader) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + cmd = grub_register_command ("appleloader", grub_cmd_appleloader, @@ -266,13 +187,13 @@ index 74888c463ba..69c2a10d351 100644 GRUB_MOD_FINI(appleloader) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + grub_unregister_command (cmd); } diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index ef87b06cf70..5aa3a5dc7dd 100644 +index b54cf6986fc..3ff305b1d32 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -34,6 +34,7 @@ @@ -284,10 +205,10 @@ index ef87b06cf70..5aa3a5dc7dd 100644 #include #include diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c -index 3730ed38247..5b9b92d6ba5 100644 +index 5f3290ce17b..54befc26626 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c -@@ -39,6 +39,7 @@ +@@ -40,6 +40,7 @@ #ifdef GRUB_MACHINE_PCBIOS #include #endif @@ -295,92 +216,92 @@ index 3730ed38247..5b9b92d6ba5 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -2130,6 +2131,9 @@ static grub_command_t cmd_netbsd_module_elf, cmd_openbsd_ramdisk; +@@ -2137,6 +2138,9 @@ static grub_command_t cmd_netbsd_module_elf, cmd_openbsd_ramdisk; GRUB_MOD_INIT (bsd) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + /* Net and OpenBSD kernels are often compressed. */ grub_dl_load ("gzio"); -@@ -2169,6 +2173,9 @@ GRUB_MOD_INIT (bsd) +@@ -2176,6 +2180,9 @@ GRUB_MOD_INIT (bsd) GRUB_MOD_FINI (bsd) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + grub_unregister_extcmd (cmd_freebsd); grub_unregister_extcmd (cmd_openbsd); grub_unregister_extcmd (cmd_netbsd); diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index b255c950526..376c726928a 100644 +index dccf3bb3005..4aeb0e4b9a6 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c -@@ -36,6 +36,7 @@ - #include +@@ -37,6 +37,7 @@ #include #include + #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -@@ -1131,6 +1132,9 @@ static grub_command_t cmd_linux, cmd_initrd; +@@ -1138,6 +1139,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, -@@ -1140,6 +1144,9 @@ GRUB_MOD_INIT(linux) +@@ -1147,6 +1151,9 @@ GRUB_MOD_INIT(linux) GRUB_MOD_FINI(linux) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + grub_unregister_command (cmd_linux); grub_unregister_command (cmd_initrd); } diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 73fb91e0570..fe3e1d41d09 100644 +index 4b1750e360e..e3fa1221e81 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c -@@ -35,6 +35,7 @@ - #include +@@ -36,6 +36,7 @@ #include #include + #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -@@ -483,6 +484,9 @@ static grub_command_t cmd_linux, cmd_linux16, cmd_initrd, cmd_initrd16; +@@ -487,6 +488,9 @@ static grub_command_t cmd_linux, cmd_linux16, cmd_initrd, cmd_initrd16; GRUB_MOD_INIT(linux16) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, N_("Load Linux.")); -@@ -500,6 +504,9 @@ GRUB_MOD_INIT(linux16) +@@ -504,6 +508,9 @@ GRUB_MOD_INIT(linux16) GRUB_MOD_FINI(linux16) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + grub_unregister_command (cmd_linux); grub_unregister_command (cmd_linux16); grub_unregister_command (cmd_initrd); diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 4a98d708259..3e6ad166dc9 100644 +index facb13f3d36..47e481f4576 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -50,6 +50,7 @@ @@ -395,7 +316,7 @@ index 4a98d708259..3e6ad166dc9 100644 GRUB_MOD_INIT(multiboot) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + cmd_multiboot = @@ -405,49 +326,49 @@ index 4a98d708259..3e6ad166dc9 100644 GRUB_MOD_FINI(multiboot) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + grub_unregister_command (cmd_multiboot); grub_unregister_command (cmd_module); } diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c -index 7f74d1d6fc9..e0f47e72b06 100644 +index 1c0cf6a430a..baa54e652ab 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c -@@ -34,6 +34,7 @@ - #include +@@ -35,6 +35,7 @@ #include #include + #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -@@ -1478,6 +1479,9 @@ static grub_extcmd_t cmd_splash; +@@ -1497,6 +1498,9 @@ static grub_extcmd_t cmd_splash; GRUB_MOD_INIT(xnu) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0, N_("Load XNU image.")); cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64, -@@ -1518,6 +1522,9 @@ GRUB_MOD_INIT(xnu) +@@ -1540,6 +1544,9 @@ GRUB_MOD_INIT(xnu) GRUB_MOD_FINI(xnu) { -+ if (grub_efi_secure_boot()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) + return; + #ifndef GRUB_MACHINE_EMU grub_unregister_command (cmd_resume); #endif diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 6840bfee9b7..090c8621066 100644 +index 6295df85f3f..585fa6662b6 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h -@@ -85,7 +85,6 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, +@@ -91,7 +91,6 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, const grub_efi_guid_t *guid, void *data, grub_size_t datasize); @@ -455,41 +376,6 @@ index 6840bfee9b7..090c8621066 100644 int EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, const grub_efi_device_path_t *dp2); -diff --git a/include/grub/efi/sb.h b/include/grub/efi/sb.h -new file mode 100644 -index 00000000000..9629fbb0f9e ---- /dev/null -+++ b/include/grub/efi/sb.h -@@ -0,0 +1,29 @@ -+/* sb.h - declare functions for EFI Secure Boot support */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_EFI_SB_HEADER -+#define GRUB_EFI_SB_HEADER 1 -+ -+#include -+#include -+ -+/* Functions. */ -+int EXPORT_FUNC (grub_efi_secure_boot) (void); -+ -+#endif /* ! GRUB_EFI_SB_HEADER */ diff --git a/include/grub/ia64/linux.h b/include/grub/ia64/linux.h new file mode 100644 index 00000000000..e69de29bb2d @@ -502,15 +388,3 @@ index 00000000000..e69de29bb2d diff --git a/include/grub/sparc64/linux.h b/include/grub/sparc64/linux.h new file mode 100644 index 00000000000..e69de29bb2d -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index 3ea8e7ff45f..c6ba5b2d763 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -71,6 +71,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h diff --git a/0006-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch b/0006-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch index 274321e..f3aae38 100644 --- a/0006-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch +++ b/0006-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch @@ -245,10 +245,10 @@ index 6b24cbb9483..3017d0f3e52 100644 if (kernel_mem && !loaded) grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index ce30e7fb01b..a093679cb80 100644 +index eddf9251d9a..25ef52c04eb 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h -@@ -136,7 +136,12 @@ struct linux_i386_kernel_header +@@ -138,7 +138,12 @@ struct linux_i386_kernel_header grub_uint32_t kernel_alignment; grub_uint8_t relocatable; grub_uint8_t min_alignment; diff --git a/0007-re-write-.gitignore.patch b/0007-re-write-.gitignore.patch index 2573139..74cb0da 100644 --- a/0007-re-write-.gitignore.patch +++ b/0007-re-write-.gitignore.patch @@ -4,14 +4,14 @@ Date: Mon, 8 Jul 2019 12:55:29 +0200 Subject: [PATCH] re-write .gitignore --- - .gitignore | 366 +++++++++++++++----------------------- - docs/.gitignore | 5 + - grub-core/.gitignore | 16 ++ + .gitignore | 152 ++++++++++++++++++++++++++++++++++++++ + docs/.gitignore | 5 ++ + grub-core/.gitignore | 16 ++++ grub-core/lib/.gitignore | 1 + include/grub/gcrypt/.gitignore | 2 + - po/.gitignore | 5 + + po/.gitignore | 5 ++ util/bash-completion.d/.gitignore | 2 + - 7 files changed, 171 insertions(+), 226 deletions(-) + 7 files changed, 183 insertions(+) create mode 100644 docs/.gitignore create mode 100644 grub-core/.gitignore create mode 100644 grub-core/lib/.gitignore @@ -20,10 +20,14 @@ Subject: [PATCH] re-write .gitignore create mode 100644 util/bash-completion.d/.gitignore diff --git a/.gitignore b/.gitignore -index 819cd185d44..b45a633f3d1 100644 +index f6a1bd05175..594d0134d33 100644 --- a/.gitignore +++ b/.gitignore -@@ -1,237 +1,151 @@ +@@ -275,3 +275,155 @@ widthspec.bin + /xfs_test + /xzcompress_test + /zfs_test ++======= +# things ./autogen.sh will create +/Makefile.utilgcry.def +/ABOUT-NLS @@ -36,45 +40,7 @@ index 819cd185d44..b45a633f3d1 100644 +/Makefile + +# things very common editors create that we never want - *~ --00_header --10_* --20_linux_xen --30_os-prober --40_custom --41_custom --*.1 --*.8 --ABOUT-NLS --aclocal.m4 --ahci_test --ascii.bitmaps --ascii.h --autom4te.cache --build-aux --build-grub-gen-asciih --build-grub-gen-widthspec --build-grub-mkfont --cdboot_test --cmp_test --config.cache --config.guess --config.h --config-util.h --config-util.h.in --config.log --config.status --config.sub --configure --core_compress_test --DISTLIST --docs/*.info --docs/stamp-vti --docs/version.texi --ehci_test --example_grub_script_test --example_scripted_test --example_unit_test ++*~ +.*.sw? +*.patch + @@ -87,207 +53,22 @@ index 819cd185d44..b45a633f3d1 100644 +*.a +*.am +*.efi - *.exec --*.exec.exe --fddboot_test --genkernsyms.sh --gensymlist.sh --gentrigtables --gentrigtables.exe --gettext_strings_test --/gnulib --grub-bin2h --/grub-bios-setup --/grub-bios-setup.exe --grub_cmd_date --grub_cmd_echo --grub_cmd_regexp --grub_cmd_set_date --grub_cmd_sleep --/grub-editenv --/grub-editenv.exe --grub-emu --grub-emu-lite --grub-emu.exe --grub-emu-lite.exe --grub_emu_init.c --grub_emu_init.h --/grub-file --/grub-file.exe --grub-fstest --grub-fstest.exe --grub_fstest_init.c --grub_fstest_init.h --grub_func_test --grub-install --grub-install.exe --grub-kbdcomp --/grub-macbless --/grub-macbless.exe --grub-macho2img --/grub-menulst2cfg --/grub-menulst2cfg.exe --/grub-mk* --grub-mount --/grub-ofpathname --/grub-ofpathname.exe --grub-core/build-grub-pe2elf.exe --/grub-probe --/grub-probe.exe --grub_probe_init.c --grub_probe_init.h --/grub-reboot --grub_script_blanklines --grub_script_blockarg --grub_script_break --grub-script-check --grub-script-check.exe --grub_script_check_init.c --grub_script_check_init.h --grub_script_comments --grub_script_continue --grub_script_dollar --grub_script_echo1 --grub_script_echo_keywords --grub_script_escape_comma --grub_script_eval --grub_script_expansion --grub_script_final_semicolon --grub_script_for1 --grub_script_functions --grub_script_gettext --grub_script_if --grub_script_leading_whitespace --grub_script_no_commands --grub_script_not --grub_script_return --grub_script_setparams --grub_script_shift --grub_script_strcmp --grub_script_test --grub_script_vars1 --grub_script_while1 --grub_script.tab.c --grub_script.tab.h --grub_script.yy.c --grub_script.yy.h --grub-set-default --grub_setup_init.c --grub_setup_init.h --grub-shell --grub-shell-tester --grub-sparc64-setup --grub-sparc64-setup.exe --/grub-syslinux2cfg --/grub-syslinux2cfg.exe --gzcompress_test --hddboot_test --help_test --*.img - *.image --*.image.exe --include/grub/cpu --include/grub/machine --INSTALL.grub --install-sh --lib/libgcrypt-grub --libgrub_a_init.c --*.log ++*.exec ++*.image +*.img +*.info - *.lst --lzocompress_test - *.marker --Makefile - /m4 - *.mod --mod-*.c --missing --netboot_test ++*.lst ++*.marker ++/m4 ++*.mod +*.module - *.o --*.a --ohci_test --partmap_test --pata_test - *.pf2 --*.pp --po/*.mo --po/grub.pot --po/Makefile.in.in --po/Makevars --po/Makevars.template --po/POTFILES --po/Rules-quot --po/stamp-po --printf_test --priority_queue_unit_test --pseries_test --stamp-h --stamp-h1 --stamp-h.in --symlist.c --symlist.h --trigtables.c --*.trs --uhci_test --update-grub_lib --unidata.c --xzcompress_test --Makefile.in --GPATH --GRTAGS --GSYMS --GTAGS --compile --depcomp --mdate-sh --texinfo.tex --grub-core/lib/libgcrypt-grub --.deps --.deps-util --.deps-core ++*.o ++*.pf2 +*.yy.[ch] +.deps/ +.deps-core/ +.deps-util/ - .dirstamp --Makefile.util.am --contrib --grub-core/bootinfo.txt --grub-core/Makefile.core.am --grub-core/Makefile.gcry.def --grub-core/contrib --grub-core/gdb_grub --grub-core/genmod.sh --grub-core/gensyminfo.sh --grub-core/gmodule.pl --grub-core/grub.chrp --grub-core/modinfo.sh --grub-core/*.module --grub-core/*.module.exe --grub-core/*.pp --grub-core/kernel.img.bin --util/bash-completion.d/grub --grub-core/lib/gnulib --grub-core/rs_decoder.h --widthspec.bin --widthspec.h --docs/stamp-1 --docs/version-dev.texi --Makefile.utilgcry.def --po/*.po --po/*.gmo --po/LINGUAS --po/remove-potcdate.sed --include/grub/gcrypt/gcrypt.h --include/grub/gcrypt/g10lib.h --po/POTFILES.in --po/POTFILES-shell.in --/grub-glue-efi --/grub-render-label --/grub-glue-efi.exe --/grub-render-label.exe ++.dirstamp + +# next are things you get if you do ./configure in the topdir (for e.g. +# "make dist" invocation. @@ -320,10 +101,7 @@ index 819cd185d44..b45a633f3d1 100644 +/build-grub-gen-widthspec +/build-grub-mkfont +/config-util.h.in - /garbage-gen --/garbage-gen.exe --/grub-fs-tester --grub-core/build-grub-module-verifier ++/garbage-gen +/grub*-bios-setup +/grub*-bios-setup.8 +/grub*-editenv diff --git a/0008-IBM-client-architecture-CAS-reboot-support.patch b/0008-IBM-client-architecture-CAS-reboot-support.patch index 4c12e5a..eaaf9a4 100644 --- a/0008-IBM-client-architecture-CAS-reboot-support.patch +++ b/0008-IBM-client-architecture-CAS-reboot-support.patch @@ -96,10 +96,10 @@ index 4d493ab7661..3a6689abb11 100644 + return 0; +} diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 1b03dfd57b9..222e239c1be 100644 +index c4ebe9e22ad..70614de1565 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -33,6 +33,9 @@ +@@ -34,6 +34,9 @@ #include #include #include @@ -109,7 +109,7 @@ index 1b03dfd57b9..222e239c1be 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -275,6 +278,22 @@ grub_normal_execute (const char *config, int nested, int batch) +@@ -276,6 +279,22 @@ grub_normal_execute (const char *config, int nested, int batch) { menu = read_config_file (config); @@ -133,7 +133,7 @@ index 1b03dfd57b9..222e239c1be 100644 grub_errno = GRUB_ERR_NONE; } diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index ee299fd0ea6..0d05d6b0709 100644 +index 25158407dd8..ad80399246a 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -28,6 +28,9 @@ @@ -146,7 +146,7 @@ index ee299fd0ea6..0d05d6b0709 100644 /* Max digits for a char is 3 (0xFF is 255), similarly for an int it is sizeof (int) * 3, and one extra for a possible -ve sign. */ -@@ -878,6 +881,10 @@ grub_script_execute_sourcecode (const char *source) +@@ -883,6 +886,10 @@ grub_script_execute_sourcecode (const char *source) grub_err_t ret = 0; struct grub_script *parsed_script; diff --git a/0009-for-ppc-reset-console-display-attr-when-clear-screen.patch b/0009-for-ppc-reset-console-display-attr-when-clear-screen.patch index ac67453..fd86ef1 100644 --- a/0009-for-ppc-reset-console-display-attr-when-clear-screen.patch +++ b/0009-for-ppc-reset-console-display-attr-when-clear-screen.patch @@ -15,7 +15,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c -index d317efa368d..29df35e6d20 100644 +index cd720080375..44d0b3b19fb 100644 --- a/grub-core/term/terminfo.c +++ b/grub-core/term/terminfo.c @@ -151,7 +151,7 @@ grub_terminfo_set_current (struct grub_term_output *term, diff --git a/0011-Honor-a-symlink-when-generating-configuration-by-gru.patch b/0011-Honor-a-symlink-when-generating-configuration-by-gru.patch deleted file mode 100644 index 2b953a6..0000000 --- a/0011-Honor-a-symlink-when-generating-configuration-by-gru.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Marcel Kolaja -Date: Tue, 21 Jan 2014 10:57:08 -0500 -Subject: [PATCH] Honor a symlink when generating configuration by - grub2-mkconfig - -Honor a symlink when generating configuration by grub2-mkconfig, so that -the -o option follows it rather than overwriting it with a regular file. ---- - util/grub-mkconfig.in | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 9f477ff0546..523d4e029bb 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -287,7 +287,8 @@ and /etc/grub.d/* files or please file a bug report with - exit 1 - else - # none of the children aborted with error, install the new grub.cfg -- mv -f ${grub_cfg}.new ${grub_cfg} -+ cat ${grub_cfg}.new > ${grub_cfg} -+ rm -f ${grub_cfg}.new - fi - fi - diff --git a/0012-Move-bash-completion-script-922997.patch b/0011-Move-bash-completion-script-922997.patch similarity index 92% rename from 0012-Move-bash-completion-script-922997.patch rename to 0011-Move-bash-completion-script-922997.patch index e3af586..606e39b 100644 --- a/0012-Move-bash-completion-script-922997.patch +++ b/0011-Move-bash-completion-script-922997.patch @@ -10,10 +10,10 @@ Apparently these go in a new place now. 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 7656f2434e5..d283af64c8c 100644 +index 74719416c4c..c0103b30d4e 100644 --- a/configure.ac +++ b/configure.ac -@@ -305,6 +305,14 @@ AC_SUBST(grubdirname) +@@ -314,6 +314,14 @@ AC_SUBST(grubdirname) AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname", [Default grub directory name]) @@ -28,7 +28,7 @@ index 7656f2434e5..d283af64c8c 100644 # # Checks for build programs. # -@@ -516,6 +524,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" +@@ -525,6 +533,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" # Check for target programs. # diff --git a/0014-Allow-fallback-to-include-entries-by-title-not-just-.patch b/0012-Allow-fallback-to-include-entries-by-title-not-just-.patch similarity index 90% rename from 0014-Allow-fallback-to-include-entries-by-title-not-just-.patch rename to 0012-Allow-fallback-to-include-entries-by-title-not-just-.patch index ee5d1da..f2a4a82 100644 --- a/0014-Allow-fallback-to-include-entries-by-title-not-just-.patch +++ b/0012-Allow-fallback-to-include-entries-by-title-not-just-.patch @@ -12,10 +12,10 @@ Signed-off-by: Peter Jones 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index d5e0c79a70e..9175ad297d8 100644 +index 8397886fa05..d7a222e681b 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c -@@ -163,16 +163,41 @@ grub_menu_set_timeout (int timeout) +@@ -163,15 +163,40 @@ grub_menu_set_timeout (int timeout) } } @@ -51,14 +51,13 @@ index d5e0c79a70e..9175ad297d8 100644 -get_and_remove_first_entry_number (const char *name) +get_and_remove_first_entry_number (grub_menu_t menu, const char *name) { - const char *val; - char *tail; + const char *val, *tail; int entry; + int sz = 0; val = grub_env_get (name); if (! val) -@@ -182,9 +207,39 @@ get_and_remove_first_entry_number (const char *name) +@@ -181,9 +206,39 @@ get_and_remove_first_entry_number (const char *name) entry = (int) grub_strtoul (val, &tail, 0); @@ -99,7 +98,7 @@ index d5e0c79a70e..9175ad297d8 100644 while (*tail && grub_isspace (*tail)) tail++; grub_env_set (name, tail); -@@ -347,7 +402,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu, +@@ -346,7 +401,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu, grub_menu_execute_entry (entry, 1); /* Deal with fallback entries. */ @@ -108,7 +107,7 @@ index d5e0c79a70e..9175ad297d8 100644 >= 0) { grub_print_error (); -@@ -465,30 +520,6 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer) +@@ -464,30 +519,6 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer) viewers = viewer; } diff --git a/0016-Make-exit-take-a-return-code.patch b/0013-Make-exit-take-a-return-code.patch similarity index 93% rename from 0016-Make-exit-take-a-return-code.patch rename to 0013-Make-exit-take-a-return-code.patch index 0cd25b2..39d7057 100644 --- a/0016-Make-exit-take-a-return-code.patch +++ b/0013-Make-exit-take-a-return-code.patch @@ -27,10 +27,10 @@ Signed-off-by: Peter Jones 14 files changed, 48 insertions(+), 21 deletions(-) diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c -index 6bbce3128cf..6d66b7c453a 100644 +index fa498931ed2..2bd3ac76f2d 100644 --- a/grub-core/commands/minicmd.c +++ b/grub-core/commands/minicmd.c -@@ -179,12 +179,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), +@@ -182,12 +182,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), } /* exit */ @@ -60,10 +60,10 @@ index 6bbce3128cf..6d66b7c453a 100644 } diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 6e1ceb90516..370ce03c5d7 100644 +index 8cff7be0289..05d8237a9b2 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -164,11 +164,16 @@ grub_reboot (void) +@@ -165,11 +165,16 @@ grub_reboot (void) } void @@ -96,10 +96,10 @@ index 425bb960347..55ea5a11ccd 100644 grub_reboot (); } diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index 65db79baa10..19cd007d448 100644 +index dfd8a8ec488..0ff13bcaf8c 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c -@@ -139,9 +139,10 @@ xasprintf (const char *fmt, ...) +@@ -151,9 +151,10 @@ xasprintf (const char *fmt, ...) #if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) void @@ -152,7 +152,7 @@ index d483e35eed2..e71d1584164 100644 grub_ieee1275_exit (); } diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c -index 3834a149093..86b3a25ec40 100644 +index 2ed3ff3191e..5c40c34078d 100644 --- a/grub-core/kern/mips/arc/init.c +++ b/grub-core/kern/mips/arc/init.c @@ -276,7 +276,7 @@ grub_halt (void) @@ -191,10 +191,10 @@ index be88b77d22d..8b6c55ffc01 100644 grub_halt (); } diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 3b633d51f4c..cd63a8cea73 100644 +index 3af336ee227..63b586d09cb 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1095,9 +1095,18 @@ grub_abort (void) +@@ -1209,9 +1209,18 @@ grub_abort (void) grub_getkey (); } @@ -253,10 +253,10 @@ index 782ca72952a..708b060f324 100644 struct sched_shutdown arg; diff --git a/include/grub/misc.h b/include/grub/misc.h -index ee48eb7a726..f9135b62e35 100644 +index 7d2b5519690..fd18e6320b8 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h -@@ -334,7 +334,7 @@ int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt, +@@ -353,7 +353,7 @@ int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt, char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT; char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) WARN_UNUSED_RESULT; diff --git a/0013-Update-to-minilzo-2.08.patch b/0013-Update-to-minilzo-2.08.patch deleted file mode 100644 index a71c501..0000000 --- a/0013-Update-to-minilzo-2.08.patch +++ /dev/null @@ -1,8509 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 4 Dec 2014 15:36:09 -0500 -Subject: [PATCH] Update to minilzo-2.08 - -This fixes CVE-2014-4607 - lzo: lzo1x_decompress_safe() integer overflow - -Signed-off-by: Peter Jones ---- - grub-core/lib/minilzo/minilzo.c | 3801 +++++++++++++++++++++++++++------------ - grub-core/lib/minilzo/lzoconf.h | 216 ++- - grub-core/lib/minilzo/lzodefs.h | 2320 ++++++++++++++++++------ - grub-core/lib/minilzo/minilzo.h | 21 +- - 4 files changed, 4489 insertions(+), 1869 deletions(-) - -diff --git a/grub-core/lib/minilzo/minilzo.c b/grub-core/lib/minilzo/minilzo.c -index 25a1f68b3b5..ab2be5f4fd0 100644 ---- a/grub-core/lib/minilzo/minilzo.c -+++ b/grub-core/lib/minilzo/minilzo.c -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -67,12 +52,6 @@ - #if defined(__CYGWIN32__) && !defined(__CYGWIN__) - # define __CYGWIN__ __CYGWIN32__ - #endif --#if defined(__IBMCPP__) && !defined(__IBMC__) --# define __IBMC__ __IBMCPP__ --#endif --#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) --# define __INTEL_COMPILER __ICL --#endif - #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) - # define _ALL_SOURCE 1 - #endif -@@ -81,19 +60,30 @@ - # define __LONG_MAX__ 9223372036854775807L - # endif - #endif --#if defined(__INTEL_COMPILER) && defined(__linux__) -+#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) -+#if defined(__ARMCC_VERSION) -+# pragma diag_suppress 193 -+#elif defined(__clang__) && defined(__clang_minor__) -+# pragma clang diagnostic ignored "-Wundef" -+#elif defined(__INTEL_COMPILER) - # pragma warning(disable: 193) --#endif --#if defined(__KEIL__) && defined(__C166__) -+#elif defined(__KEIL__) && defined(__C166__) - # pragma warning disable = 322 --#elif 0 && defined(__C251__) --# pragma warning disable = 322 --#endif --#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) --# if (_MSC_VER >= 1300) -+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) -+# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) -+# pragma GCC diagnostic ignored "-Wundef" -+# endif -+#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -+# if ((_MSC_VER-0) >= 1300) - # pragma warning(disable: 4668) - # endif - #endif -+#endif -+#if 0 && defined(__POCC__) && defined(_WIN32) -+# if (__POCC__ >= 400) -+# pragma warn(disable: 2216) -+# endif -+#endif - #if 0 && defined(__WATCOMC__) - # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) - # pragma warning 203 9 -@@ -102,13 +92,29 @@ - #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) - # pragma option -h - #endif -+#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) -+#ifndef _CRT_NONSTDC_NO_DEPRECATE -+#define _CRT_NONSTDC_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_NONSTDC_NO_WARNINGS -+#define _CRT_NONSTDC_NO_WARNINGS 1 -+#endif -+#ifndef _CRT_SECURE_NO_DEPRECATE -+#define _CRT_SECURE_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_SECURE_NO_WARNINGS -+#define _CRT_SECURE_NO_WARNINGS 1 -+#endif -+#endif - #if 0 --#define LZO_0xffffL 0xfffful --#define LZO_0xffffffffL 0xfffffffful -+#define LZO_0xffffUL 0xfffful -+#define LZO_0xffffffffUL 0xfffffffful - #else --#define LZO_0xffffL 65535ul --#define LZO_0xffffffffL 4294967295ul -+#define LZO_0xffffUL 65535ul -+#define LZO_0xffffffffUL 4294967295ul - #endif -+#define LZO_0xffffL LZO_0xffffUL -+#define LZO_0xffffffffL LZO_0xffffffffUL - #if (LZO_0xffffL == LZO_0xffffffffL) - # error "your preprocessor is broken 1" - #endif -@@ -123,6 +129,13 @@ - # error "your preprocessor is broken 4" - #endif - #endif -+#if defined(__COUNTER__) -+# ifndef LZO_CFG_USE_COUNTER -+# define LZO_CFG_USE_COUNTER 1 -+# endif -+#else -+# undef LZO_CFG_USE_COUNTER -+#endif - #if (UINT_MAX == LZO_0xffffL) - #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) - # if !defined(MSDOS) -@@ -253,14 +266,31 @@ - #endif - #define LZO_PP_STRINGIZE(x) #x - #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) -+#define LZO_PP_CONCAT0() /*empty*/ -+#define LZO_PP_CONCAT1(a) a - #define LZO_PP_CONCAT2(a,b) a ## b - #define LZO_PP_CONCAT3(a,b,c) a ## b ## c - #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g -+#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() -+#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) - #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) - #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) - #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) - #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) -+#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) -+#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) -+#define LZO_PP_EMPTY /*empty*/ -+#define LZO_PP_EMPTY0() /*empty*/ -+#define LZO_PP_EMPTY1(a) /*empty*/ -+#define LZO_PP_EMPTY2(a,b) /*empty*/ -+#define LZO_PP_EMPTY3(a,b,c) /*empty*/ -+#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ -+#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ -+#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ -+#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ - #if 1 - #define LZO_CPP_STRINGIZE(x) #x - #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) -@@ -268,12 +298,16 @@ - #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c - #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g - #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) - #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) - #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) - #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) -+#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) -+#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) - #endif --#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) -+#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) - #if 1 && defined(__cplusplus) - # if !defined(__STDC_CONSTANT_MACROS) - # define __STDC_CONSTANT_MACROS 1 -@@ -283,9 +317,13 @@ - # endif - #endif - #if defined(__cplusplus) --# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C_BEGIN extern "C" { -+# define LZO_EXTERN_C_END } - #else --# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C_BEGIN /*empty*/ -+# define LZO_EXTERN_C_END /*empty*/ - #endif - #if !defined(__LZO_OS_OVERRIDE) - #if (LZO_OS_FREESTANDING) -@@ -386,12 +424,12 @@ - #elif defined(__VMS) - # define LZO_OS_VMS 1 - # define LZO_INFO_OS "vms" --#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PS2 1 - # define LZO_INFO_OS "console" - # define LZO_INFO_OS_CONSOLE "ps2" --#elif (defined(__mips__) && defined(__psp__)) -+#elif defined(__mips__) && defined(__psp__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PSP 1 - # define LZO_INFO_OS "console" -@@ -419,9 +457,18 @@ - # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) - # define LZO_OS_POSIX_LINUX 1 - # define LZO_INFO_OS_POSIX "linux" --# elif defined(__APPLE__) || defined(__MACOS__) --# define LZO_OS_POSIX_MACOSX 1 --# define LZO_INFO_OS_POSIX "macosx" -+# elif defined(__APPLE__) && defined(__MACH__) -+# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) -+# define LZO_OS_POSIX_DARWIN 1040 -+# define LZO_INFO_OS_POSIX "darwin_iphone" -+# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) -+# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -+# define LZO_INFO_OS_POSIX "darwin" -+# else -+# define LZO_OS_POSIX_DARWIN 1 -+# define LZO_INFO_OS_POSIX "darwin" -+# endif -+# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN - # elif defined(__minix__) || defined(__minix) - # define LZO_OS_POSIX_MINIX 1 - # define LZO_INFO_OS_POSIX "minix" -@@ -456,18 +503,18 @@ - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) - # if (UINT_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) -@@ -483,59 +530,65 @@ - # define LZO_INFO_CC "sdcc" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) - #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) --# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) -+# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) - # define LZO_INFO_CC "Pathscale C" - # define LZO_INFO_CCVER __PATHSCALE__ --#elif defined(__INTEL_COMPILER) --# define LZO_CC_INTELC 1 -+# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# endif -+#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) -+# define LZO_CC_INTELC __INTEL_COMPILER - # define LZO_INFO_CC "Intel C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) --# if defined(_WIN32) || defined(_WIN64) --# define LZO_CC_SYNTAX_MSC 1 --# else --# define LZO_CC_SYNTAX_GNUC 1 -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_INTELC_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif - #elif defined(__POCC__) && defined(_WIN32) - # define LZO_CC_PELLESC 1 - # define LZO_INFO_CC "Pelles C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) --#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) - # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) --# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) -+# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) - # else --# define LZO_CC_CLANG_CLANG 0x010000L -+# define LZO_CC_CLANG 0x010000L -+# endif -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_CLANG_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif --# define LZO_CC_CLANG LZO_CC_CLANG_GNUC - # define LZO_INFO_CC "clang" - # define LZO_INFO_CCVER __VERSION__ - #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif - # define LZO_CC_LLVM LZO_CC_LLVM_GNUC - # define LZO_INFO_CC "llvm-gcc" - # define LZO_INFO_CCVER __VERSION__ --#elif defined(__GNUC__) && defined(__VERSION__) --# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) --# elif defined(__GNUC_MINOR__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) --# else --# define LZO_CC_GNUC (__GNUC__ * 0x10000L) --# endif --# define LZO_INFO_CC "gcc" --# define LZO_INFO_CCVER __VERSION__ - #elif defined(__ACK__) && defined(_ACK) - # define LZO_CC_ACK 1 - # define LZO_INFO_CC "Amsterdam Compiler Kit C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) - #elif defined(__AZTEC_C__) - # define LZO_CC_AZTECC 1 - # define LZO_INFO_CC "Aztec C" -@@ -560,10 +613,23 @@ - # define LZO_CC_DECC 1 - # define LZO_INFO_CC "DEC C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) -+#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) -+# define LZO_CC_GHS 1 -+# define LZO_INFO_CC "Green Hills C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_GHS_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# endif - #elif defined(__HIGHC__) - # define LZO_CC_HIGHC 1 - # define LZO_INFO_CC "MetaWare High C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) -+# define LZO_CC_HPACC __HP_aCC -+# define LZO_INFO_CC "HP aCC" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) - #elif defined(__IAR_SYSTEMS_ICC__) - # define LZO_CC_IARC 1 - # define LZO_INFO_CC "IAR C" -@@ -572,10 +638,14 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(__IBMC__) --# define LZO_CC_IBMC 1 -+#elif defined(__IBMC__) && ((__IBMC__-0) > 0) -+# define LZO_CC_IBMC __IBMC__ - # define LZO_INFO_CC "IBM C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) -+#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) -+# define LZO_CC_IBMC __IBMCPP__ -+# define LZO_INFO_CC "IBM C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) - #elif defined(__KEIL__) && defined(__C166__) - # define LZO_CC_KEILC 1 - # define LZO_INFO_CC "Keil C" -@@ -592,16 +662,8 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(_MSC_VER) --# define LZO_CC_MSC 1 --# define LZO_INFO_CC "Microsoft C" --# if defined(_MSC_FULL_VER) --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) --# else --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) --# endif --#elif defined(__MWERKS__) --# define LZO_CC_MWERKS 1 -+#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) -+# define LZO_CC_MWERKS __MWERKS__ - # define LZO_INFO_CC "Metrowerks C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) - #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) -@@ -612,6 +674,15 @@ - # define LZO_CC_PACIFICC 1 - # define LZO_INFO_CC "Pacific C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) -+#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) -+# if defined(__PGIC_PATCHLEVEL__) -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) -+# else -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" -+# endif -+# define LZO_INFO_CC "Portland Group PGI C" - #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) - # define LZO_CC_PGI 1 - # define LZO_INFO_CC "Portland Group PGI C" -@@ -626,7 +697,7 @@ - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) - #elif defined(__SUNPRO_C) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_C)+0 > 0) -+# if ((__SUNPRO_C-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_C - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) - # else -@@ -635,7 +706,7 @@ - # endif - #elif defined(__SUNPRO_CC) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_CC)+0 > 0) -+# if ((__SUNPRO_CC-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_CC - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) - # else -@@ -661,16 +732,46 @@ - #elif defined(__ZTC__) - # define LZO_CC_ZORTECHC 1 - # define LZO_INFO_CC "Zortech C" --# if (__ZTC__ == 0x310) -+# if ((__ZTC__-0) == 0x310) - # define LZO_INFO_CCVER "0x310" - # else - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) - # endif -+#elif defined(__GNUC__) && defined(__VERSION__) -+# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# elif defined(__GNUC_MINOR__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) -+# else -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L) -+# endif -+# define LZO_INFO_CC "gcc" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_MSC _MSC_VER -+# define LZO_INFO_CC "Microsoft C" -+# if defined(_MSC_FULL_VER) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) -+# else -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) -+# endif - #else - # define LZO_CC_UNKNOWN 1 - # define LZO_INFO_CC "unknown" - # define LZO_INFO_CCVER "unknown" - #endif -+#if (LZO_CC_GNUC) && defined(__OPEN64__) -+# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) -+# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) -+# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC -+# endif -+#endif -+#if (LZO_CC_GNUC) && defined(__PCC__) -+# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) -+# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) -+# define LZO_CC_PCC_GNUC LZO_CC_GNUC -+# endif -+#endif - #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) - # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" - #endif -@@ -688,8 +789,10 @@ - # define LZO_INFO_ARCH "generic" - #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086 1 --# define LZO_ARCH_IA16 1 - # define LZO_INFO_ARCH "i086" -+#elif defined(__aarch64__) -+# define LZO_ARCH_ARM64 1 -+# define LZO_INFO_ARCH "arm64" - #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) - # define LZO_ARCH_ALPHA 1 - # define LZO_INFO_ARCH "alpha" -@@ -705,10 +808,10 @@ - # define LZO_INFO_ARCH "arm_thumb" - #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) - # define LZO_ARCH_ARM 1 --# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) -+# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) - # define LZO_ARCH_ARM_THUMB 1 - # define LZO_INFO_ARCH "arm_thumb" --# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) -+# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) - # define LZO_INFO_ARCH "arm" - # else - # define LZO_INFO_ARCH "arm" -@@ -826,53 +929,147 @@ - # error "FIXME - missing define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) --# error "FIXME - missing WIN32 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) --# error "FIXME - missing WIN64 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" - #endif - #if (LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #endif --#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) --# error "this should not happen" -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) -+# define LZO_ARCH_X64 1 -+#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_AMD64 1 - #endif --#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) --# error "this should not happen" -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) -+# define LZO_ARCH_AARCH64 1 -+#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_ARM64 1 -+#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) -+# define LZO_ARCH_X86 1 -+#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_I386 1 -+#endif -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) -+# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ARCH_I086) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_ARCH_I386) - # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif --#if !defined(__LZO_MM_OVERRIDE) -+#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# if !defined(LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSE2__) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_SSSE3) -+# if (LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSSE3__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# elif defined(_MSC_VER) && defined(__AVX__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_SSE4_2) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__SSE4_2__) -+# define LZO_TARGET_FEATURE_SSE4_2 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__AVX__) -+# define LZO_TARGET_FEATURE_AVX 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX2) -+# if (LZO_TARGET_FEATURE_AVX) -+# if defined(__AVX2__) -+# define LZO_TARGET_FEATURE_AVX2 1 -+# endif -+# endif -+# endif -+#endif -+#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if defined(__ARM_NEON__) -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if 1 -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif -+# endif -+#endif -+#if 0 -+#elif !defined(__LZO_MM_OVERRIDE) - #if (LZO_ARCH_I086) - #if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif - #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) - # define LZO_MM_TINY 1 -@@ -899,7 +1096,7 @@ - #elif (LZO_CC_ZORTECHC && defined(__VCM__)) - # define LZO_MM_LARGE 1 - #else --# error "unknown memory model" -+# error "unknown LZO_ARCH_I086 memory model" - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - #define LZO_HAVE_MM_HUGE_PTR 1 -@@ -922,10 +1119,10 @@ - #endif - #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) - # if (LZO_OS_DOS16) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # elif (LZO_CC_ZORTECHC) - # else --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #ifdef __cplusplus -@@ -957,7 +1154,7 @@ extern "C" { - #endif - #elif (LZO_ARCH_C166) - #if !defined(__MODEL__) --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 1) -@@ -971,11 +1168,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #endif - #elif (LZO_ARCH_MCS251) - #if !defined(__MODEL__) --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -987,11 +1184,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #endif - #elif (LZO_ARCH_MCS51) - #if !defined(__MODEL__) --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #elif ((__MODEL__) == 1) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -1003,7 +1200,7 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #endif - #elif (LZO_ARCH_CRAY_PVP) - # define LZO_MM_PVP 1 -@@ -1030,35 +1227,818 @@ extern "C" { - # error "unknown memory model" - #endif - #endif -+#if !defined(__lzo_gnuc_extension__) -+#if (LZO_CC_GNUC >= 0x020800ul) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_gnuc_extension__ __extension__ -+#else -+#endif -+#endif -+#if !defined(__lzo_gnuc_extension__) -+# define __lzo_gnuc_extension__ /*empty*/ -+#endif -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 -+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# else -+# define LZO_CFG_USE_NEW_STYLE_CASTS 1 -+# endif -+#endif -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+#endif -+#if !defined(__cplusplus) -+# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# undef LZO_CFG_USE_NEW_STYLE_CASTS -+# endif -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+#endif -+#if !defined(LZO_REINTERPRET_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) -+# endif -+#endif -+#if !defined(LZO_REINTERPRET_CAST) -+# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) -+#endif -+#if !defined(LZO_STATIC_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_STATIC_CAST(t,e) (static_cast (e)) -+# endif -+#endif -+#if !defined(LZO_STATIC_CAST) -+# define LZO_STATIC_CAST(t,e) ((t) (e)) -+#endif -+#if !defined(LZO_STATIC_CAST2) -+# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) -+#endif -+#if !defined(LZO_UNCONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) -+# endif -+#endif -+#if !defined(LZO_UNCONST_CAST) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) -+#endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif -+#endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) -+#endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) -+# endif -+#endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) -+#endif -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif -+#endif -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) -+#endif -+#if !defined(LZO_PCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_PCAST(t,e) ((t) (e)) -+# endif -+#endif -+#if !defined(LZO_PCAST) -+# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) -+#endif -+#if !defined(LZO_CCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_CCAST(t,e) ((t) (e)) -+# endif -+#endif -+#if !defined(LZO_CCAST) -+# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) -+#endif -+#if !defined(LZO_ICONV) -+# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(LZO_ICAST) -+# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(LZO_ITRUNC) -+# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(__lzo_cte) -+# if (LZO_CC_MSC || LZO_CC_WATCOMC) -+# define __lzo_cte(e) ((void)0,(e)) -+# elif 1 -+# define __lzo_cte(e) ((void)0,(e)) -+# endif -+#endif -+#if !defined(__lzo_cte) -+# define __lzo_cte(e) (e) -+#endif -+#if !defined(LZO_BLOCK_BEGIN) -+# define LZO_BLOCK_BEGIN do { -+# define LZO_BLOCK_END } while __lzo_cte(0) -+#endif -+#if !defined(LZO_UNUSED) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNUSED(var) ((void) var) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_KEILC) -+# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} -+# elif (LZO_CC_PACIFICC) -+# define LZO_UNUSED(var) ((void) sizeof(var)) -+# elif (LZO_CC_WATCOMC) && defined(__cplusplus) -+# define LZO_UNUSED(var) ((void) var) -+# else -+# define LZO_UNUSED(var) ((void) &var) -+# endif -+#endif -+#if !defined(LZO_UNUSED_FUNC) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED_FUNC(func) ((void) func) -+# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_CLANG || LZO_CC_LLVM) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_MSC) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_KEILC || LZO_CC_PELLESC) -+# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} -+# else -+# define LZO_UNUSED_FUNC(func) ((void) func) -+# endif -+#endif -+#if !defined(LZO_UNUSED_LABEL) -+# if (LZO_CC_CLANG >= 0x020800ul) -+# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) -+# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -+# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l -+# else -+# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l -+# endif -+#endif -+#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -+# if 0 -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var -+# elif 0 && (LZO_CC_GNUC) -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -+# else -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -+# endif -+#endif -+#if !defined(__lzo_inline) -+#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) -+#elif defined(__cplusplus) -+# define __lzo_inline inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_inline inline -+#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) -+# define __lzo_inline __inline -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_DMC) -+# define __lzo_inline __inline -+#elif (LZO_CC_GHS) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_INTELC) -+# define __lzo_inline __inline -+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) -+# define __lzo_inline __inline -+#elif (LZO_CC_MSC && (_MSC_VER >= 900)) -+# define __lzo_inline __inline -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_inline __inline__ -+#endif -+#endif -+#if defined(__lzo_inline) -+# ifndef __lzo_HAVE_inline -+# define __lzo_HAVE_inline 1 -+# endif -+#else -+# define __lzo_inline /*empty*/ -+#endif -+#if !defined(__lzo_forceinline) -+#if (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_forceinline __forceinline -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_forceinline __forceinline -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#endif -+#endif -+#if defined(__lzo_forceinline) -+# ifndef __lzo_HAVE_forceinline -+# define __lzo_HAVE_forceinline 1 -+# endif -+#else -+# define __lzo_forceinline __lzo_inline -+#endif -+#if !defined(__lzo_noinline) -+#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) -+# define __lzo_noinline __attribute__((__noinline__,__used__)) -+#elif (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noinline __declspec(noinline) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_noinline __declspec(noinline) -+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) -+# if defined(__cplusplus) -+# else -+# define __lzo_noinline __declspec(noinline) -+# endif -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_noinline __attribute__((__noinline__)) -+#endif -+#endif -+#if defined(__lzo_noinline) -+# ifndef __lzo_HAVE_noinline -+# define __lzo_HAVE_noinline 1 -+# endif -+#else -+# define __lzo_noinline /*empty*/ -+#endif -+#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if !defined(__lzo_static_inline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline -+#endif -+#endif -+#if !defined(__lzo_static_inline) -+# define __lzo_static_inline static __lzo_inline -+#endif -+#if !defined(__lzo_static_forceinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline -+#endif -+#endif -+#if !defined(__lzo_static_forceinline) -+# define __lzo_static_forceinline static __lzo_forceinline -+#endif -+#if !defined(__lzo_static_noinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline -+#endif -+#endif -+#if !defined(__lzo_static_noinline) -+# define __lzo_static_noinline static __lzo_noinline -+#endif -+#if !defined(__lzo_c99_extern_inline) -+#if defined(__GNUC_GNU_INLINE__) -+# define __lzo_c99_extern_inline __lzo_inline -+#elif defined(__GNUC_STDC_INLINE__) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#endif -+#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) -+# define __lzo_c99_extern_inline __lzo_inline -+#endif -+#endif -+#if defined(__lzo_c99_extern_inline) -+# ifndef __lzo_HAVE_c99_extern_inline -+# define __lzo_HAVE_c99_extern_inline 1 -+# endif -+#else -+# define __lzo_c99_extern_inline /*empty*/ -+#endif -+#if !defined(__lzo_may_alias) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_CLANG >= 0x020900ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#endif -+#endif -+#if defined(__lzo_may_alias) -+# ifndef __lzo_HAVE_may_alias -+# define __lzo_HAVE_may_alias 1 -+# endif -+#else -+# define __lzo_may_alias /*empty*/ -+#endif -+#if !defined(__lzo_noreturn) -+#if (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#endif -+#endif -+#if defined(__lzo_noreturn) -+# ifndef __lzo_HAVE_noreturn -+# define __lzo_HAVE_noreturn 1 -+# endif -+#else -+# define __lzo_noreturn /*empty*/ -+#endif -+#if !defined(__lzo_nothrow) -+#if (LZO_CC_GNUC >= 0x030300ul) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) -+#endif -+#endif -+#if defined(__lzo_nothrow) -+# ifndef __lzo_HAVE_nothrow -+# define __lzo_HAVE_nothrow 1 -+# endif -+#else -+# define __lzo_nothrow /*empty*/ -+#endif -+#if !defined(__lzo_restrict) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_IBMC >= 1210) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) -+# define __lzo_restrict __restrict -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_restrict __restrict__ -+#endif -+#endif -+#if defined(__lzo_restrict) -+# ifndef __lzo_HAVE_restrict -+# define __lzo_HAVE_restrict 1 -+# endif -+#else -+# define __lzo_restrict /*empty*/ -+#endif -+#if !defined(__lzo_alignof) -+#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_GHS) && !defined(__cplusplus) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_alignof(e) __alignof(e) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_alignof(e) __alignof__(e) -+#endif -+#endif -+#if defined(__lzo_alignof) -+# ifndef __lzo_HAVE_alignof -+# define __lzo_HAVE_alignof 1 -+# endif -+#endif -+#if !defined(__lzo_struct_packed) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { -+# define __lzo_struct_packed_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_struct_packed(s) _Packed struct s { -+# define __lzo_struct_packed_end() }; -+#endif -+#endif -+#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) -+# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) -+#endif -+#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) -+# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() -+#endif -+#if !defined(__lzo_byte_struct) -+#if defined(__lzo_struct_packed) -+# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() -+# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() -+#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); -+# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); -+#endif -+#endif -+#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) -+# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) -+#endif -+#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) -+#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) -+#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_CILLY || LZO_CC_PCC) -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_align16(s) struct __declspec(align(16)) s { -+# define __lzo_struct_align16_end() }; -+# define __lzo_struct_align32(s) struct __declspec(align(32)) s { -+# define __lzo_struct_align32_end() }; -+# define __lzo_struct_align64(s) struct __declspec(align(64)) s { -+# define __lzo_struct_align64_end() }; -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_struct_align16(s) struct s { -+# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); -+# define __lzo_struct_align32(s) struct s { -+# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); -+# define __lzo_struct_align64(s) struct s { -+# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); -+#endif -+#endif -+#if !defined(__lzo_union_um) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_union_um(s) __pragma(pack(push,1)) union s { -+# define __lzo_union_um_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_union_um(s) _Packed union s { -+# define __lzo_union_um_end() }; -+#endif -+#endif -+#if !defined(__lzo_union_am) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() }; -+#endif -+#if !defined(__lzo_constructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_constructor __attribute__((__constructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_constructor __attribute__((__constructor__)) -+#endif -+#endif -+#if defined(__lzo_constructor) -+# ifndef __lzo_HAVE_constructor -+# define __lzo_HAVE_constructor 1 -+# endif -+#endif -+#if !defined(__lzo_destructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_destructor __attribute__((__destructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_destructor __attribute__((__destructor__)) -+#endif -+#endif -+#if defined(__lzo_destructor) -+# ifndef __lzo_HAVE_destructor -+# define __lzo_HAVE_destructor 1 -+# endif -+#endif -+#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if !defined(__lzo_likely) && !defined(__lzo_unlikely) -+#if (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_IBMC >= 1010) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#endif -+#endif -+#if defined(__lzo_likely) -+# ifndef __lzo_HAVE_likely -+# define __lzo_HAVE_likely 1 -+# endif -+#else -+# define __lzo_likely(e) (e) -+#endif -+#if defined(__lzo_unlikely) -+# ifndef __lzo_HAVE_unlikely -+# define __lzo_HAVE_unlikely 1 -+# endif -+#else -+# define __lzo_unlikely(e) (e) -+#endif -+#if !defined(__lzo_static_unused_void_func) -+# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) -+# else -+# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) -+# endif -+#endif -+#if !defined(__lzo_loop_forever) -+# if (LZO_CC_IBMC) -+# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END -+# else -+# define __lzo_loop_forever() do { ; } while __lzo_cte(1) -+# endif -+#endif -+#if !defined(__lzo_unreachable) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_GNUC >= 0x040500ul) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 -+# define __lzo_unreachable() __builtin_unreachable(); -+#endif -+#endif -+#if defined(__lzo_unreachable) -+# ifndef __lzo_HAVE_unreachable -+# define __lzo_HAVE_unreachable 1 -+# endif -+#else -+# if 0 -+# define __lzo_unreachable() ((void)0); -+# else -+# define __lzo_unreachable() __lzo_loop_forever(); -+# endif -+#endif -+#ifndef __LZO_CTA_NAME -+#if (LZO_CFG_USE_COUNTER) -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) -+#else -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) -+#endif -+#endif -+#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) -+# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END -+# else -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END -+# endif -+#endif -+#if !defined(LZO_COMPILE_TIME_ASSERT) -+# if (LZO_CC_AZTECC) -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} -+# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} -+# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} -+# elif (LZO_CC_GNUC >= 0x040700ul) -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# else -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} -+# endif -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) -+#if defined(__cplusplus) -+extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) -+#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) -+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) -+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -+# define __lzo_cdecl __cdecl -+# define __lzo_cdecl_atexit /*empty*/ -+# define __lzo_cdecl_main __cdecl -+# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -+# define __lzo_cdecl_qsort __pascal -+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -+# define __lzo_cdecl_qsort _stdcall -+# else -+# define __lzo_cdecl_qsort __cdecl -+# endif -+# elif (LZO_CC_WATCOMC) -+# define __lzo_cdecl __cdecl -+# else -+# define __lzo_cdecl __cdecl -+# define __lzo_cdecl_atexit __cdecl -+# define __lzo_cdecl_main __cdecl -+# define __lzo_cdecl_qsort __cdecl -+# endif -+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) -+# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -+# define __lzo_cdecl_sighandler __pascal -+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -+# define __lzo_cdecl_sighandler _stdcall -+# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) -+# define __lzo_cdecl_sighandler __clrcall -+# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) -+# if defined(_DLL) -+# define __lzo_cdecl_sighandler _far _cdecl _loadds -+# elif defined(_MT) -+# define __lzo_cdecl_sighandler _far _cdecl -+# else -+# define __lzo_cdecl_sighandler _cdecl -+# endif -+# else -+# define __lzo_cdecl_sighandler __cdecl -+# endif -+#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) -+# define __lzo_cdecl __cdecl -+#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) -+# define __lzo_cdecl cdecl -+#endif -+#if !defined(__lzo_cdecl) -+# define __lzo_cdecl /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_atexit) -+# define __lzo_cdecl_atexit /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_main) -+# define __lzo_cdecl_main /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_qsort) -+# define __lzo_cdecl_qsort /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_sighandler) -+# define __lzo_cdecl_sighandler /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_va) -+# define __lzo_cdecl_va __lzo_cdecl -+#endif -+#if !(LZO_CFG_NO_WINDOWS_H) -+#if !defined(LZO_HAVE_WINDOWS_H) -+#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) -+# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) -+# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) -+# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) -+# else -+# define LZO_HAVE_WINDOWS_H 1 -+# endif -+#endif -+#endif -+#endif -+#ifndef LZO_SIZEOF_SHORT - #if defined(SIZEOF_SHORT) - # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -+#elif defined(__SIZEOF_SHORT__) -+# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) - #endif -+#endif -+#ifndef LZO_SIZEOF_INT - #if defined(SIZEOF_INT) - # define LZO_SIZEOF_INT (SIZEOF_INT) -+#elif defined(__SIZEOF_INT__) -+# define LZO_SIZEOF_INT (__SIZEOF_INT__) - #endif -+#endif -+#ifndef LZO_SIZEOF_LONG - #if defined(SIZEOF_LONG) - # define LZO_SIZEOF_LONG (SIZEOF_LONG) -+#elif defined(__SIZEOF_LONG__) -+# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) - #endif -+#endif -+#ifndef LZO_SIZEOF_LONG_LONG - #if defined(SIZEOF_LONG_LONG) - # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -+#elif defined(__SIZEOF_LONG_LONG__) -+# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) - #endif -+#endif -+#ifndef LZO_SIZEOF___INT16 - #if defined(SIZEOF___INT16) - # define LZO_SIZEOF___INT16 (SIZEOF___INT16) - #endif -+#endif -+#ifndef LZO_SIZEOF___INT32 - #if defined(SIZEOF___INT32) - # define LZO_SIZEOF___INT32 (SIZEOF___INT32) - #endif -+#endif -+#ifndef LZO_SIZEOF___INT64 - #if defined(SIZEOF___INT64) - # define LZO_SIZEOF___INT64 (SIZEOF___INT64) - #endif -+#endif -+#ifndef LZO_SIZEOF_VOID_P - #if defined(SIZEOF_VOID_P) - # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -+#elif defined(__SIZEOF_POINTER__) -+# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) - #endif -+#endif -+#ifndef LZO_SIZEOF_SIZE_T - #if defined(SIZEOF_SIZE_T) - # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -+#elif defined(__SIZEOF_SIZE_T__) -+# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) - #endif -+#endif -+#ifndef LZO_SIZEOF_PTRDIFF_T - #if defined(SIZEOF_PTRDIFF_T) - # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -+#elif defined(__SIZEOF_PTRDIFF_T__) -+# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) -+#endif - #endif - #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) - #if !defined(LZO_SIZEOF_SHORT) -@@ -1080,6 +2060,7 @@ extern "C" { - # error "LZO_SIZEOF_SHORT" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) - #if !defined(LZO_SIZEOF_INT) - # if (LZO_ARCH_CRAY_PVP) - # define LZO_SIZEOF_INT 8 -@@ -1101,6 +2082,7 @@ extern "C" { - # error "LZO_SIZEOF_INT" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) - #if !defined(LZO_SIZEOF_LONG) - # if (ULONG_MAX == LZO_0xffffffffL) - # define LZO_SIZEOF_LONG 4 -@@ -1110,6 +2092,8 @@ extern "C" { - # define LZO_SIZEOF_LONG 2 - # elif (__LZO_LSR(ULONG_MAX,31) == 1) - # define LZO_SIZEOF_LONG 4 -+# elif (__LZO_LSR(ULONG_MAX,39) == 1) -+# define LZO_SIZEOF_LONG 5 - # elif (__LZO_LSR(ULONG_MAX,63) == 1) - # define LZO_SIZEOF_LONG 8 - # elif (__LZO_LSR(ULONG_MAX,127) == 1) -@@ -1118,11 +2102,12 @@ extern "C" { - # error "LZO_SIZEOF_LONG" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) - #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) - #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) - # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) - # if (LZO_CC_GNUC >= 0x030300ul) --# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) -+# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) - # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG - # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) - # define LZO_SIZEOF_LONG_LONG 4 -@@ -1136,7 +2121,7 @@ extern "C" { - #if (LZO_ARCH_I086 && LZO_CC_DMC) - #elif (LZO_CC_CILLY) && defined(__GNUC__) - # define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define LZO_SIZEOF_LONG_LONG 8 - #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) - # define LZO_SIZEOF_LONG_LONG 8 -@@ -1158,11 +2143,13 @@ extern "C" { - # define LZO_SIZEOF___INT64 8 - #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) - # define LZO_SIZEOF___INT64 8 --#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) -+#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) - # define LZO_SIZEOF___INT64 8 - #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) - # define LZO_SIZEOF_LONG_LONG 8 --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) - # define LZO_SIZEOF_LONG_LONG 8 - #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) - #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -@@ -1175,87 +2162,127 @@ extern "C" { - # undef LZO_SIZEOF_LONG_LONG - # endif - #endif --#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) -+#if (LZO_CFG_NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(__NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(_NO_LONGLONG) - # undef LZO_SIZEOF_LONG_LONG - #endif --#if !defined(LZO_SIZEOF_VOID_P) --#if (LZO_ARCH_I086) --# define __LZO_WORDSIZE 2 --# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) --# define LZO_SIZEOF_VOID_P 2 --# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) --# define LZO_SIZEOF_VOID_P 4 -+#if !defined(LZO_WORDSIZE) -+#if (LZO_ARCH_ALPHA) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AMD64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AVR) -+# define LZO_WORDSIZE 1 -+#elif (LZO_ARCH_H8300) -+# if defined(__NORMAL_MODE__) -+# define LZO_WORDSIZE 4 -+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -+# define LZO_WORDSIZE 4 - # else --# error "LZO_MM" -+# define LZO_WORDSIZE 2 - # endif --#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) --# define __LZO_WORDSIZE 1 -+#elif (LZO_ARCH_I086) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_IA64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_M16C) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_SPU) -+# define LZO_WORDSIZE 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_WORDSIZE 1 -+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+# define LZO_WORDSIZE 8 -+#elif (LZO_OS_OS400 || defined(__OS400__)) -+# define LZO_WORDSIZE 8 -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_WORDSIZE 8 -+#endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 4 -+#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif (LZO_ARCH_AVR) - # define LZO_SIZEOF_VOID_P 2 - #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) - # define LZO_SIZEOF_VOID_P 2 - #elif (LZO_ARCH_H8300) - # if defined(__NORMAL_MODE__) --# define __LZO_WORDSIZE 4 - # define LZO_SIZEOF_VOID_P 2 - # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) --# define __LZO_WORDSIZE 4 - # define LZO_SIZEOF_VOID_P 4 - # else --# define __LZO_WORDSIZE 2 - # define LZO_SIZEOF_VOID_P 2 - # endif - # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) - # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT - # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT - # endif -+#elif (LZO_ARCH_I086) -+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -+# define LZO_SIZEOF_VOID_P 2 -+# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# error "invalid LZO_ARCH_I086 memory model" -+# endif - #elif (LZO_ARCH_M16C) --# define __LZO_WORDSIZE 2 - # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) - # define LZO_SIZEOF_VOID_P 4 - # else - # define LZO_SIZEOF_VOID_P 2 - # endif -+#elif (LZO_ARCH_SPU) -+# define LZO_SIZEOF_VOID_P 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_SIZEOF_VOID_P 2 - #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) --# define __LZO_WORDSIZE 8 - # define LZO_SIZEOF_VOID_P 4 --#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) --# define __LZO_WORDSIZE 8 --# define LZO_SIZEOF_VOID_P 8 --#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - #elif (LZO_OS_OS400 || defined(__OS400__)) --# define __LZO_WORDSIZE LZO_SIZEOF_LONG --# define LZO_SIZEOF_VOID_P 16 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) --# define LZO_SIZEOF_VOID_P 8 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (LZO_ARCH_SPU) --# if 0 --# define __LZO_WORDSIZE 16 --# endif --# define LZO_SIZEOF_VOID_P 4 --#else --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --#endif --#endif --#if !defined(LZO_WORDSIZE) --# if defined(__LZO_WORDSIZE) --# define LZO_WORDSIZE __LZO_WORDSIZE -+# if defined(__LLP64_IFC__) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - # else --# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -+# define LZO_SIZEOF_VOID_P 16 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - # endif -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - #endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) - #if !defined(LZO_SIZEOF_SIZE_T) - #if (LZO_ARCH_I086 || LZO_ARCH_M16C) - # define LZO_SIZEOF_SIZE_T 2 --#else -+#endif -+#endif -+#if !defined(LZO_SIZEOF_SIZE_T) - # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P - #endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) - #endif - #if !defined(LZO_SIZEOF_PTRDIFF_T) - #if (LZO_ARCH_I086) -@@ -1268,11 +2295,18 @@ extern "C" { - # define LZO_SIZEOF_PTRDIFF_T 2 - # endif - # else --# error "LZO_MM" -+# error "invalid LZO_ARCH_I086 memory model" - # endif --#else -+#endif -+#endif -+#if !defined(LZO_SIZEOF_PTRDIFF_T) - # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T - #endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) -+#endif -+#if !defined(LZO_WORDSIZE) -+# define LZO_WORDSIZE LZO_SIZEOF_VOID_P - #endif - #if (LZO_ABI_NEUTRAL_ENDIAN) - # undef LZO_ABI_BIG_ENDIAN -@@ -1284,7 +2318,7 @@ extern "C" { - # define LZO_ABI_LITTLE_ENDIAN 1 - #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) - # define LZO_ABI_LITTLE_ENDIAN 1 --#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) -+#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) - # if (__LITTLE_ENDIAN__ == 1) -@@ -1300,6 +2334,19 @@ extern "C" { - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) - # define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) -+# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) -+# error "unexpected configuration - check your compiler defines" -+# elif defined(__BIG_ENDIAN) -+# define LZO_ABI_BIG_ENDIAN 1 -+# else -+# define LZO_ABI_LITTLE_ENDIAN 1 -+# endif -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 - #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -@@ -1307,7 +2354,7 @@ extern "C" { - #endif - #endif - #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ABI_BIG_ENDIAN) - # define LZO_INFO_ABI_ENDIAN "be" -@@ -1322,6 +2369,9 @@ extern "C" { - #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) - # define LZO_ABI_ILP16 1 - # define LZO_INFO_ABI_PM "ilp16" -+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_LP32 1 -+# define LZO_INFO_ABI_PM "lp32" - #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) - # define LZO_ABI_ILP32 1 - # define LZO_INFO_ABI_PM "ilp32" -@@ -1338,7 +2388,8 @@ extern "C" { - # define LZO_ABI_IP32L64 1 - # define LZO_INFO_ABI_PM "ip32l64" - #endif --#if !defined(__LZO_LIBC_OVERRIDE) -+#if 0 -+#elif !defined(__LZO_LIBC_OVERRIDE) - #if (LZO_LIBC_NAKED) - # define LZO_INFO_LIBC "naked" - #elif (LZO_LIBC_FREESTANDING) -@@ -1349,6 +2400,9 @@ extern "C" { - # define LZO_INFO_LIBC "isoc90" - #elif (LZO_LIBC_ISOC99) - # define LZO_INFO_LIBC "isoc99" -+#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) -+# define LZO_LIBC_ISOC90 1 -+# define LZO_INFO_LIBC "isoc90" - #elif defined(__dietlibc__) - # define LZO_LIBC_DIETLIBC 1 - # define LZO_INFO_LIBC "dietlibc" -@@ -1357,13 +2411,13 @@ extern "C" { - # define LZO_INFO_LIBC "newlib" - #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) - # if defined(__UCLIBC_SUBLEVEL__) --# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -+# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) - # else - # define LZO_LIBC_UCLIBC 0x00090bL - # endif --# define LZO_INFO_LIBC "uclibc" -+# define LZO_INFO_LIBC "uc" "libc" - #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) --# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) -+# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) - # define LZO_INFO_LIBC "glibc" - #elif (LZO_CC_MWERKS) && defined(__MSL__) - # define LZO_LIBC_MSL __MSL__ -@@ -1376,423 +2430,159 @@ extern "C" { - # define LZO_INFO_LIBC "default" - #endif - #endif --#if !defined(__lzo_gnuc_extension__) --#if (LZO_CC_GNUC >= 0x020800ul) --# define __lzo_gnuc_extension__ __extension__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_gnuc_extension__ __extension__ --#else --# define __lzo_gnuc_extension__ /*empty*/ --#endif --#endif --#if !defined(__lzo_ua_volatile) --# define __lzo_ua_volatile volatile --#endif --#if !defined(__lzo_alignof) --#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_alignof(e) __alignof(e) --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_alignof(e) __alignof__(e) --#endif --#endif --#if defined(__lzo_alignof) --# define __lzo_HAVE_alignof 1 --#endif --#if !defined(__lzo_constructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_constructor __attribute__((__constructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_constructor __attribute__((__constructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_constructor __attribute__((__constructor__)) --#endif --#endif --#if defined(__lzo_constructor) --# define __lzo_HAVE_constructor 1 --#endif --#if !defined(__lzo_destructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_destructor __attribute__((__destructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_destructor __attribute__((__destructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_destructor __attribute__((__destructor__)) --#endif --#endif --#if defined(__lzo_destructor) --# define __lzo_HAVE_destructor 1 --#endif --#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) --# error "this should not happen" --#endif --#if !defined(__lzo_inline) --#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) --#elif defined(__cplusplus) --# define __lzo_inline inline --#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) --# define __lzo_inline __inline --#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_inline __inline__ --#elif (LZO_CC_DMC) --# define __lzo_inline __inline --#elif (LZO_CC_INTELC) --# define __lzo_inline __inline --#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) --# define __lzo_inline __inline --#elif (LZO_CC_MSC && (_MSC_VER >= 900)) --# define __lzo_inline __inline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_inline __inline__ --#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) --# define __lzo_inline inline --#endif --#endif --#if defined(__lzo_inline) --# define __lzo_HAVE_inline 1 --#else --# define __lzo_inline /*empty*/ --#endif --#if !defined(__lzo_forceinline) --#if (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_forceinline __forceinline --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_forceinline __forceinline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#endif --#endif --#if defined(__lzo_forceinline) --# define __lzo_HAVE_forceinline 1 --#else --# define __lzo_forceinline /*empty*/ --#endif --#if !defined(__lzo_noinline) --#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) --# define __lzo_noinline __attribute__((__noinline__,__used__)) --#elif (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) --# define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) --# if defined(__cplusplus) --# else --# define __lzo_noinline __declspec(noinline) --# endif --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_noinline __attribute__((__noinline__)) --#endif --#endif --#if defined(__lzo_noinline) --# define __lzo_HAVE_noinline 1 --#else --# define __lzo_noinline /*empty*/ --#endif --#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) --# error "this should not happen" --#endif --#if !defined(__lzo_noreturn) --#if (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_noreturn __declspec(noreturn) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_noreturn __declspec(noreturn) --#endif --#endif --#if defined(__lzo_noreturn) --# define __lzo_HAVE_noreturn 1 --#else --# define __lzo_noreturn /*empty*/ --#endif --#if !defined(__lzo_nothrow) --#if (LZO_CC_GNUC >= 0x030300ul) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#endif --#endif --#if defined(__lzo_nothrow) --# define __lzo_HAVE_nothrow 1 --#else --# define __lzo_nothrow /*empty*/ --#endif --#if !defined(__lzo_restrict) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) --# define __lzo_restrict __restrict --#endif --#endif --#if defined(__lzo_restrict) --# define __lzo_HAVE_restrict 1 --#else --# define __lzo_restrict /*empty*/ --#endif --#if !defined(__lzo_likely) && !defined(__lzo_unlikely) --#if (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#endif --#endif --#if defined(__lzo_likely) --# define __lzo_HAVE_likely 1 --#else --# define __lzo_likely(e) (e) --#endif --#if defined(__lzo_unlikely) --# define __lzo_HAVE_unlikely 1 --#else --# define __lzo_unlikely(e) (e) --#endif --#if !defined(LZO_UNUSED) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED(var) ((void) &var) --# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNUSED(var) ((void) var) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_KEILC) --# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} --# elif (LZO_CC_PACIFICC) --# define LZO_UNUSED(var) ((void) sizeof(var)) --# elif (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED(var) ((void) var) --# else --# define LZO_UNUSED(var) ((void) &var) --# endif --#endif --#if !defined(LZO_UNUSED_FUNC) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED_FUNC(func) ((void) func) --# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_MSC) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_KEILC || LZO_CC_PELLESC) --# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} --# else --# define LZO_UNUSED_FUNC(func) ((void) func) --# endif --#endif --#if !defined(LZO_UNUSED_LABEL) --# if (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) --# define LZO_UNUSED_LABEL(l) if (0) goto l --# else --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# endif --#endif --#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) --# if 0 --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var --# elif 0 && (LZO_CC_GNUC) --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var --# else --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init --# endif --#endif --#if !defined(LZO_UNCONST_CAST) --# if 0 && defined(__cplusplus) --# define LZO_UNCONST_CAST(t,e) (const_cast (e)) --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) --# else --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) --# endif --#endif --#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) --# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; --# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; --# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; --# else --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; --# endif --#endif --#if !defined(LZO_COMPILE_TIME_ASSERT) --# if (LZO_CC_AZTECC) --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} --# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# else --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} --# endif --#endif --#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) --# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) --# define __lzo_cdecl __cdecl --# define __lzo_cdecl_atexit /*empty*/ --# define __lzo_cdecl_main __cdecl --# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) --# define __lzo_cdecl_qsort __pascal --# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) --# define __lzo_cdecl_qsort _stdcall --# else --# define __lzo_cdecl_qsort __cdecl --# endif --# elif (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --# else --# define __lzo_cdecl __cdecl --# define __lzo_cdecl_atexit __cdecl --# define __lzo_cdecl_main __cdecl --# define __lzo_cdecl_qsort __cdecl --# endif --# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) --# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) --# define __lzo_cdecl_sighandler __pascal --# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) --# define __lzo_cdecl_sighandler _stdcall --# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) --# define __lzo_cdecl_sighandler __clrcall --# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) --# if defined(_DLL) --# define __lzo_cdecl_sighandler _far _cdecl _loadds --# elif defined(_MT) --# define __lzo_cdecl_sighandler _far _cdecl --# else --# define __lzo_cdecl_sighandler _cdecl --# endif --# else --# define __lzo_cdecl_sighandler __cdecl --# endif --#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) --# define __lzo_cdecl cdecl --#endif --#if !defined(__lzo_cdecl) --# define __lzo_cdecl /*empty*/ --#endif --#if !defined(__lzo_cdecl_atexit) --# define __lzo_cdecl_atexit /*empty*/ --#endif --#if !defined(__lzo_cdecl_main) --# define __lzo_cdecl_main /*empty*/ --#endif --#if !defined(__lzo_cdecl_qsort) --# define __lzo_cdecl_qsort /*empty*/ --#endif --#if !defined(__lzo_cdecl_sighandler) --# define __lzo_cdecl_sighandler /*empty*/ --#endif --#if !defined(__lzo_cdecl_va) --# define __lzo_cdecl_va __lzo_cdecl --#endif --#if !(LZO_CFG_NO_WINDOWS_H) --#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) --# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) --# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) --# else --# define LZO_HAVE_WINDOWS_H 1 --# endif -+#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+# define LZO_ASM_SYNTAX_MSC 1 -+#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -+#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_CC_GNUC) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#endif -+#if (LZO_ASM_SYNTAX_GNUC) -+#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -+# define __LZO_ASM_CLOBBER "ax" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) -+# define __LZO_ASM_CLOBBER "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#else -+# define __LZO_ASM_CLOBBER "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC : "cc" -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ - #endif - #endif - #if (LZO_ARCH_ALPHA) --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_AMD64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# define LZO_OPT_UNALIGNED64 1 --#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_ARM) --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# if defined(__ARM_FEATURE_UNALIGNED) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_CRIS) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_I386) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_IA64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_PREFER_POSTINC 1 - #elif (LZO_ARCH_M68K) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if defined(__mc68020__) && !defined(__mcoldfire__) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - # endif - #elif (LZO_ARCH_MIPS) --# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_POWERPC) --# define LZO_OPT_PREFER_PREINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_PREINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if (LZO_ABI_BIG_ENDIAN) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif -+# endif - # endif - #elif (LZO_ARCH_S390) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# if (LZO_SIZEOF_SIZE_T == 8) --# define LZO_OPT_UNALIGNED64 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - # endif - #elif (LZO_ARCH_SH) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - #endif - #ifndef LZO_CFG_NO_INLINE_ASM --#if (LZO_CC_LLVM) -+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) - # define LZO_CFG_NO_INLINE_ASM 1 -+#elif (LZO_CC_LLVM) -+# define LZO_CFG_NO_INLINE_ASM 1 -+#endif - #endif -+#if (LZO_CFG_NO_INLINE_ASM) -+# undef LZO_ASM_SYNTAX_MSC -+# undef LZO_ASM_SYNTAX_GNUC -+# undef __LZO_ASM_CLOBBER -+# undef __LZO_ASM_CLOBBER_LIST_CC -+# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY -+# undef __LZO_ASM_CLOBBER_LIST_EMPTY - #endif - #ifndef LZO_CFG_NO_UNALIGNED - #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) -@@ -1804,25 +2594,6 @@ extern "C" { - # undef LZO_OPT_UNALIGNED32 - # undef LZO_OPT_UNALIGNED64 - #endif --#if (LZO_CFG_NO_INLINE_ASM) --#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --# define LZO_ASM_SYNTAX_MSC 1 --#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) --#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#endif --#if (LZO_ASM_SYNTAX_GNUC) --#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) --# define __LZO_ASM_CLOBBER "ax" --#elif (LZO_CC_INTELC) --# define __LZO_ASM_CLOBBER "memory" --#else --# define __LZO_ASM_CLOBBER "cc", "memory" --#endif --#endif - #if defined(__LZO_INFOSTR_MM) - #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) - # define __LZO_INFOSTR_MM "" -@@ -1866,6 +2637,381 @@ extern "C" { - #define LZO_INFO_STRING \ - LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ - " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER -+#if !(LZO_CFG_SKIP_LZO_TYPES) -+#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if !defined(lzo_llong_t) -+#if (LZO_SIZEOF_LONG_LONG+0 > 0) -+__lzo_gnuc_extension__ typedef long long lzo_llong_t__; -+__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; -+# define lzo_llong_t lzo_llong_t__ -+# define lzo_ullong_t lzo_ullong_t__ -+#endif -+#endif -+#if !defined(lzo_int16e_t) -+#if (LZO_SIZEOF_LONG == 2) -+# define lzo_int16e_t long -+# define lzo_uint16e_t unsigned long -+#elif (LZO_SIZEOF_INT == 2) -+# define lzo_int16e_t int -+# define lzo_uint16e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 2) -+# define lzo_int16e_t short int -+# define lzo_uint16e_t unsigned short int -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) -+ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); -+ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); -+# define lzo_int16e_t lzo_int16e_hi_t__ -+# define lzo_uint16e_t lzo_uint16e_hi_t__ -+#elif (LZO_SIZEOF___INT16 == 2) -+# define lzo_int16e_t __int16 -+# define lzo_uint16e_t unsigned __int16 -+#else -+#endif -+#endif -+#if defined(lzo_int16e_t) -+# define LZO_SIZEOF_LZO_INT16E_T 2 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) -+#endif -+#if !defined(lzo_int32e_t) -+#if (LZO_SIZEOF_LONG == 4) -+# define lzo_int32e_t long int -+# define lzo_uint32e_t unsigned long int -+#elif (LZO_SIZEOF_INT == 4) -+# define lzo_int32e_t int -+# define lzo_uint32e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 4) -+# define lzo_int32e_t short int -+# define lzo_uint32e_t unsigned short int -+#elif (LZO_SIZEOF_LONG_LONG == 4) -+# define lzo_int32e_t lzo_llong_t -+# define lzo_uint32e_t lzo_ullong_t -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+#elif (LZO_SIZEOF___INT32 == 4) -+# define lzo_int32e_t __int32 -+# define lzo_uint32e_t unsigned __int32 -+#else -+#endif -+#endif -+#if defined(lzo_int32e_t) -+# define LZO_SIZEOF_LZO_INT32E_T 4 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) -+#endif -+#if !defined(lzo_int64e_t) -+#if (LZO_SIZEOF___INT64 == 8) -+# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define LZO_CFG_TYPE_PREFER___INT64 1 -+# endif -+#endif -+#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int64e_t int -+# define lzo_uint64e_t unsigned int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG == 8) -+# define lzo_int64e_t long int -+# define lzo_uint64e_t unsigned long int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define lzo_int64e_t lzo_llong_t -+# define lzo_uint64e_t lzo_ullong_t -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0ll) -+# define LZO_UINT64_C(c) ((c) + 0ull) -+# elif 0 -+# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) -+# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) -+# else -+# define LZO_INT64_C(c) (c##LL) -+# define LZO_UINT64_C(c) (c##ULL) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG -+#elif (LZO_SIZEOF___INT64 == 8) -+# define lzo_int64e_t __int64 -+# define lzo_uint64e_t unsigned __int64 -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0i64) -+# define LZO_UINT64_C(c) ((c) + 0ui64) -+# else -+# define LZO_INT64_C(c) (c##i64) -+# define LZO_UINT64_C(c) (c##ui64) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 -+#else -+#endif -+#endif -+#if defined(lzo_int64e_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) -+#endif -+#if !defined(lzo_int32l_t) -+#if defined(lzo_int32e_t) -+# define lzo_int32l_t lzo_int32e_t -+# define lzo_uint32l_t lzo_uint32e_t -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T -+#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int32l_t int -+# define lzo_uint32l_t unsigned int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= 4) -+# define lzo_int32l_t long int -+# define lzo_uint32l_t unsigned long int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG -+#else -+# error "lzo_int32l_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) -+#endif -+#if !defined(lzo_int64l_t) -+#if defined(lzo_int64e_t) -+# define lzo_int64l_t lzo_int64e_t -+# define lzo_uint64l_t lzo_uint64e_t -+# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T -+#else -+#endif -+#endif -+#if defined(lzo_int64l_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) -+#endif -+#if !defined(lzo_int32f_t) -+#if (LZO_SIZEOF_SIZE_T >= 8) -+# define lzo_int32f_t lzo_int64l_t -+# define lzo_uint32f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# define lzo_int32f_t lzo_int32l_t -+# define lzo_uint32f_t lzo_uint32l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) -+#endif -+#if !defined(lzo_int64f_t) -+#if defined(lzo_int64l_t) -+# define lzo_int64f_t lzo_int64l_t -+# define lzo_uint64f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+#endif -+#endif -+#if defined(lzo_int64f_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) -+#endif -+#if !defined(lzo_intptr_t) -+#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) -+# define __LZO_INTPTR_T_IS_POINTER 1 -+ typedef char* lzo_intptr_t; -+ typedef char* lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) -+ typedef __w64 int lzo_intptr_t; -+ typedef __w64 unsigned int lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t short -+# define lzo_uintptr_t unsigned short -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT -+#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_intptr_t int -+# define lzo_uintptr_t unsigned int -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t long -+# define lzo_uintptr_t unsigned long -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t lzo_int64l_t -+# define lzo_uintptr_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# error "lzo_intptr_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) -+#endif -+#if !defined(lzo_word_t) -+#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) -+#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) -+# define lzo_word_t lzo_uintptr_t -+# define lzo_sword_t lzo_intptr_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) -+# define lzo_word_t unsigned long -+# define lzo_sword_t long -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG -+#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) -+# define lzo_word_t unsigned int -+# define lzo_sword_t int -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT -+#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) -+# define lzo_word_t unsigned short -+# define lzo_sword_t short -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT -+#elif (LZO_WORDSIZE == 1) -+# define lzo_word_t unsigned char -+# define lzo_sword_t signed char -+# define LZO_SIZEOF_LZO_WORD_T 1 -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) -+# define lzo_word_t lzo_uint64l_t -+# define lzo_sword_t lzo_int64l_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T -+#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) -+#if 0 -+ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); -+ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); -+# define lzo_word_t lzo_word_t -+# define lzo_sword_t lzo_sword_t -+# define LZO_SIZEOF_LZO_WORD_T 16 -+#endif -+#else -+# error "lzo_word_t" -+#endif -+#endif -+#endif -+#if 1 && defined(lzo_word_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) -+#endif -+#if 1 -+#define lzo_int8_t signed char -+#define lzo_uint8_t unsigned char -+#define LZO_SIZEOF_LZO_INT8_T 1 -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) -+#endif -+#if defined(lzo_int16e_t) -+#define lzo_int16_t lzo_int16e_t -+#define lzo_uint16_t lzo_uint16e_t -+#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) -+#endif -+#if defined(lzo_int32e_t) -+#define lzo_int32_t lzo_int32e_t -+#define lzo_uint32_t lzo_uint32e_t -+#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) -+#endif -+#if defined(lzo_int64e_t) -+#define lzo_int64_t lzo_int64e_t -+#define lzo_uint64_t lzo_uint64e_t -+#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) -+#endif -+#if 1 -+#define lzo_int_least32_t lzo_int32l_t -+#define lzo_uint_least32_t lzo_uint32l_t -+#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) -+#endif -+#if defined(lzo_int64l_t) -+#define lzo_int_least64_t lzo_int64l_t -+#define lzo_uint_least64_t lzo_uint64l_t -+#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) -+#endif -+#if 1 -+#define lzo_int_fast32_t lzo_int32f_t -+#define lzo_uint_fast32_t lzo_uint32f_t -+#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) -+#endif -+#if defined(lzo_int64f_t) -+#define lzo_int_fast64_t lzo_int64f_t -+#define lzo_uint_fast64_t lzo_uint64f_t -+#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) -+#endif -+#if !defined(LZO_INT16_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) ((c) + 0) -+# define LZO_UINT16_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) ((c) + 0L) -+# define LZO_UINT16_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) (c) -+# define LZO_UINT16_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) (c##L) -+# define LZO_UINT16_C(c) (c##UL) -+# else -+# error "LZO_INT16_C" -+# endif -+#endif -+#if !defined(LZO_INT32_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) ((c) + 0) -+# define LZO_UINT32_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) ((c) + 0L) -+# define LZO_UINT32_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) (c) -+# define LZO_UINT32_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) (c##L) -+# define LZO_UINT32_C(c) (c##UL) -+# elif (LZO_SIZEOF_LONG_LONG >= 4) -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+# else -+# error "LZO_INT32_C" -+# endif -+#endif -+#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) ((c) + 0) -+# define LZO_UINT64_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) ((c) + 0L) -+# define LZO_UINT64_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) (c) -+# define LZO_UINT64_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) (c##L) -+# define LZO_UINT64_C(c) (c##UL) -+# else -+# error "LZO_INT64_C" -+# endif -+#endif -+#endif - - #endif - -@@ -1874,7 +3020,7 @@ extern "C" { - #undef LZO_HAVE_CONFIG_H - #include "minilzo.h" - --#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2050) -+#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2080) - # error "version mismatch in miniLZO source files" - #endif - -@@ -1886,23 +3032,9 @@ extern "C" { - #define __LZO_CONF_H 1 - - #if !defined(__LZO_IN_MINILZO) --#if (LZO_CFG_FREESTANDING) -+#if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING) - # define LZO_LIBC_FREESTANDING 1 - # define LZO_OS_FREESTANDING 1 --# define ACC_LIBC_FREESTANDING 1 --# define ACC_OS_FREESTANDING 1 --#endif --#if (LZO_CFG_NO_UNALIGNED) --# define ACC_CFG_NO_UNALIGNED 1 --#endif --#if (LZO_ARCH_GENERIC) --# define ACC_ARCH_GENERIC 1 --#endif --#if (LZO_ABI_NEUTRAL_ENDIAN) --# define ACC_ABI_NEUTRAL_ENDIAN 1 --#endif --#if (LZO_HAVE_CONFIG_H) --# define ACC_CONFIG_NO_HEADER 1 - #endif - #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) - # include LZO_CFG_EXTRA_CONFIG_HEADER -@@ -1911,22 +3043,27 @@ extern "C" { - # error "include this file first" - #endif - #include "lzo/lzoconf.h" -+#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) -+# include LZO_CFG_EXTRA_CONFIG_HEADER2 -+#endif - #endif - --#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) -+#if (LZO_VERSION < 0x2080) || !defined(__LZOCONF_H_INCLUDED) - # error "version mismatch" - #endif - --#if (LZO_CC_BORLANDC && LZO_ARCH_I086) --# pragma option -h -+#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) -+# pragma warning(disable: 4702) - #endif -- - #if (LZO_CC_MSC && (_MSC_VER >= 1000)) - # pragma warning(disable: 4127 4701) -+# pragma warning(disable: 4514 4710 4711) - #endif - #if (LZO_CC_MSC && (_MSC_VER >= 1300)) - # pragma warning(disable: 4820) --# pragma warning(disable: 4514 4710 4711) -+#endif -+#if (LZO_CC_MSC && (_MSC_VER >= 1800)) -+# pragma warning(disable: 4746) - #endif - - #if (LZO_CC_SUNPROC) -@@ -1937,49 +3074,16 @@ extern "C" { - #endif - #endif - --#if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR) --# error "this should not happen - check defines for __huge" --#endif -- --#if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING) --#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) --# define ACC_WANT_ACC_INCD_H 1 --# define ACC_WANT_ACC_INCE_H 1 --# define ACC_WANT_ACC_INCI_H 1 -+#if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING) - #elif 1 - # include - #else --# define ACC_WANT_ACC_INCD_H 1 -+# define LZO_WANT_ACC_INCD_H 1 - #endif -- --#if (LZO_ARCH_I086) --# define ACC_MM_AHSHIFT LZO_MM_AHSHIFT --# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) --# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) --# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) -+#if defined(LZO_HAVE_CONFIG_H) -+# define LZO_CFG_NO_CONFIG_HEADER 1 - #endif - --#if !defined(lzo_uintptr_t) --# if defined(__LZO_MMODEL_HUGE) --# define lzo_uintptr_t unsigned long --# elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) --# define __LZO_UINTPTR_T_IS_POINTER 1 -- typedef char* lzo_uintptr_t; --# define lzo_uintptr_t lzo_uintptr_t --# elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t size_t --# elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned long --# elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned int --# elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned long long --# else --# define lzo_uintptr_t size_t --# endif --#endif --LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) -- - #if 1 && !defined(LZO_CFG_FREESTANDING) - #if 1 && !defined(HAVE_STRING_H) - #define HAVE_STRING_H 1 -@@ -2002,6 +3106,23 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #include - #endif - -+#if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1) -+#endif -+#if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2) -+#endif -+#if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4) -+#endif -+#if defined(lzo_int64_t) || defined(lzo_uint64_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8) -+#endif -+ - #if (LZO_CFG_FREESTANDING) - # undef HAVE_MEMCMP - # undef HAVE_MEMCPY -@@ -2012,28 +3133,28 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #if !(HAVE_MEMCMP) - # undef memcmp - # define memcmp(a,b,c) lzo_memcmp(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memcmp - # define lzo_memcmp(a,b,c) memcmp(a,b,c) - #endif - #if !(HAVE_MEMCPY) - # undef memcpy - # define memcpy(a,b,c) lzo_memcpy(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memcpy - # define lzo_memcpy(a,b,c) memcpy(a,b,c) - #endif - #if !(HAVE_MEMMOVE) - # undef memmove - # define memmove(a,b,c) lzo_memmove(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memmove - # define lzo_memmove(a,b,c) memmove(a,b,c) - #endif - #if !(HAVE_MEMSET) - # undef memset - # define memset(a,b,c) lzo_memset(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memset - # define lzo_memset(a,b,c) memset(a,b,c) - #endif -@@ -2058,27 +3179,29 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) - #endif - --#if !defined(__lzo_inline) --# define __lzo_inline /*empty*/ --#endif --#if !defined(__lzo_forceinline) --# define __lzo_forceinline /*empty*/ --#endif --#if !defined(__lzo_noinline) --# define __lzo_noinline /*empty*/ --#endif -- - #if (LZO_CFG_PGO) --# undef __acc_likely --# undef __acc_unlikely - # undef __lzo_likely - # undef __lzo_unlikely --# define __acc_likely(e) (e) --# define __acc_unlikely(e) (e) - # define __lzo_likely(e) (e) - # define __lzo_unlikely(e) (e) - #endif - -+#undef _ -+#undef __ -+#undef ___ -+#undef ____ -+#undef _p0 -+#undef _p1 -+#undef _p2 -+#undef _p3 -+#undef _p4 -+#undef _s0 -+#undef _s1 -+#undef _s2 -+#undef _s3 -+#undef _s4 -+#undef _ww -+ - #if 1 - # define LZO_BYTE(x) ((unsigned char) (x)) - #else -@@ -2097,84 +3220,548 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #define LZO_SIZE(bits) (1u << (bits)) - #define LZO_MASK(bits) (LZO_SIZE(bits) - 1) - --#define LZO_LSIZE(bits) (1ul << (bits)) --#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) -- - #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) - #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) - - #if !defined(DMUL) - #if 0 - --# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) -+# define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) - #else - # define DMUL(a,b) ((lzo_xint) ((a) * (b))) - #endif - #endif - --#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC) --# if (LZO_SIZEOF_SHORT == 2) --# define LZO_UNALIGNED_OK_2 1 --# endif --# if (LZO_SIZEOF_INT == 4) --# define LZO_UNALIGNED_OK_4 1 --# endif --#endif --#if 1 && (LZO_ARCH_AMD64) --# if defined(LZO_UINT64_MAX) --# define LZO_UNALIGNED_OK_8 1 --# endif --#endif --#if (LZO_CFG_NO_UNALIGNED) --# undef LZO_UNALIGNED_OK_2 --# undef LZO_UNALIGNED_OK_4 --# undef LZO_UNALIGNED_OK_8 --#endif -- --#undef UA_GET16 --#undef UA_SET16 --#undef UA_COPY16 --#undef UA_GET32 --#undef UA_SET32 --#undef UA_COPY32 --#undef UA_GET64 --#undef UA_SET64 --#undef UA_COPY64 --#if defined(LZO_UNALIGNED_OK_2) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2) --# if 1 && defined(ACC_UA_COPY16) --# define UA_GET16 ACC_UA_GET16 --# define UA_SET16 ACC_UA_SET16 --# define UA_COPY16 ACC_UA_COPY16 --# else --# define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v)) --# define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s)) --# endif --#endif --#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) --# if 1 && defined(ACC_UA_COPY32) --# define UA_GET32 ACC_UA_GET32 --# define UA_SET32 ACC_UA_SET32 --# define UA_COPY32 ACC_UA_COPY32 --# else --# define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v)) --# define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s)) --# endif --#endif --#if defined(LZO_UNALIGNED_OK_8) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64) == 8) --# if 1 && defined(ACC_UA_COPY64) --# define UA_GET64 ACC_UA_GET64 --# define UA_SET64 ACC_UA_SET64 --# define UA_COPY64 ACC_UA_COPY64 --# else --# define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v)) --# define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s)) --# endif -+#ifndef __LZO_FUNC_H -+#define __LZO_FUNC_H 1 -+ -+#if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN) -+#if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC) -+#define LZO_BITOPS_USE_ASM_BITSCAN 1 -+#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul)))) -+#define LZO_BITOPS_USE_GNUC_BITSCAN 1 -+#elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) -+#define LZO_BITOPS_USE_MSC_BITSCAN 1 -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+#include -+#endif -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+#pragma intrinsic(_BitScanReverse) -+#pragma intrinsic(_BitScanForward) -+#endif -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64) -+#pragma intrinsic(_BitScanReverse64) -+#pragma intrinsic(_BitScanForward64) -+#endif -+#endif -+#endif -+ -+__lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+ unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31; -+#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint32_t r; -+ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r ^ 31; -+#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4) -+ unsigned r; r = (unsigned) __builtin_clz(v); return r; -+#define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+ -+#if defined(lzo_uint64_t) -+__lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) -+ unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63; -+#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint64_t r; -+ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r ^ 63; -+#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_clzl(v); return r; -+#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v)) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_clzll(v); return r; -+#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+#endif -+ -+__lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+ unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r; -+#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint32_t r; -+ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r; -+#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4) -+ unsigned r; r = (unsigned) __builtin_ctz(v); return r; -+#define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+ -+#if defined(lzo_uint64_t) -+__lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) -+ unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r; -+#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint64_t r; -+ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r; -+#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_ctzl(v); return r; -+#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v)) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_ctzll(v); return r; -+#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+#endif -+ -+#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+static void __attribute__((__unused__)) -+#else -+__lzo_static_forceinline void -+#endif -+lzo_bitops_unused_funcs(void) -+{ -+ LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func); -+ LZO_UNUSED_FUNC(lzo_bitops_cttz32_func); -+#if defined(lzo_uint64_t) -+ LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func); -+ LZO_UNUSED_FUNC(lzo_bitops_cttz64_func); -+#endif -+ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); -+} -+ -+#if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED) -+#ifndef __lzo_memops_tcheck -+#define __lzo_memops_tcheck(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b)) -+#endif -+#endif -+#ifndef lzo_memops_TU0p -+#define lzo_memops_TU0p void __LZO_MMODEL * -+#endif -+#ifndef lzo_memops_TU1p -+#define lzo_memops_TU1p unsigned char __LZO_MMODEL * -+#endif -+#ifndef lzo_memops_TU2p -+#if (LZO_OPT_UNALIGNED16) -+typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2; -+#define lzo_memops_TU2p volatile lzo_memops_TU2 * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU2_struct,2) -+typedef struct lzo_memops_TU2_struct lzo_memops_TU2; -+#else -+struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias; -+typedef struct lzo_memops_TU2_struct lzo_memops_TU2; -+#endif -+#ifndef lzo_memops_TU2p -+#define lzo_memops_TU2p lzo_memops_TU2 * -+#endif -+#endif -+#ifndef lzo_memops_TU4p -+#if (LZO_OPT_UNALIGNED32) -+typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4; -+#define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU4_struct,4) -+typedef struct lzo_memops_TU4_struct lzo_memops_TU4; -+#else -+struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias; -+typedef struct lzo_memops_TU4_struct lzo_memops_TU4; -+#endif -+#ifndef lzo_memops_TU4p -+#define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL * -+#endif -+#endif -+#ifndef lzo_memops_TU8p -+#if (LZO_OPT_UNALIGNED64) -+typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8; -+#define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU8_struct,8) -+typedef struct lzo_memops_TU8_struct lzo_memops_TU8; -+#else -+struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias; -+typedef struct lzo_memops_TU8_struct lzo_memops_TU8; -+#endif -+#ifndef lzo_memops_TU8p -+#define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL * -+#endif -+#endif -+#ifndef lzo_memops_set_TU1p -+#define lzo_memops_set_TU1p volatile lzo_memops_TU1p -+#endif -+#ifndef lzo_memops_move_TU1p -+#define lzo_memops_move_TU1p lzo_memops_TU1p -+#endif -+#define LZO_MEMOPS_SET1(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__1[0] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET2(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET3(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET4(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE1(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__1[0] = s__1[0]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE2(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__2[0] = s__2[0]; d__2[1] = s__2[1]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE3(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE4(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE8(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \ -+ d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \ -+ LZO_BLOCK_END -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1) -+#define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss) -+#if (LZO_OPT_UNALIGNED16) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) -+#define LZO_MEMOPS_COPY2(dd,ss) \ -+ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY2(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU2,2,1)) { \ -+ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss) -+#endif -+#if (LZO_OPT_UNALIGNED32) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) -+#define LZO_MEMOPS_COPY4(dd,ss) \ -+ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY4(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU4,4,1)) { \ -+ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss) -+#endif -+#if (LZO_WORDSIZE != 8) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END -+#else -+#if (LZO_OPT_UNALIGNED64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) -+#elif (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU8,8,1)) { \ -+ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss) -+#endif -+#endif -+#define LZO_MEMOPS_COPYN(dd,ss,nn) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \ -+ lzo_uint n__n = (nn); \ -+ while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \ -+ if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \ -+ if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ -+ LZO_BLOCK_END -+ -+__lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) -+{ -+ lzo_uint16_t v; -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY2(&v, ss); -+#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss; -+ unsigned long vv; -+ __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); -+ v = (lzo_uint16_t) vv; -+#else -+ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; -+ v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8)); -+#endif -+ return v; -+} -+#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss) -+#endif -+ -+__lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss) -+{ -+ lzo_uint32_t v; -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY4(&v, ss); -+#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss; -+ unsigned long vv; -+ __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); -+ v = (lzo_uint32_t) vv; -+#else -+ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; -+ v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24)); -+#endif -+ return v; -+} -+#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss) -+#endif -+ -+#if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) -+#endif -+ -+__lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss) -+{ -+ lzo_uint16_t v; -+ LZO_MEMOPS_COPY2(&v, ss); -+ return v; -+} -+#if (LZO_OPT_UNALIGNED16) -+#define LZO_MEMOPS_GET_NE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss) -+#endif -+ -+__lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss) -+{ -+ lzo_uint32_t v; -+ LZO_MEMOPS_COPY4(&v, ss); -+ return v; -+} -+#if (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_GET_NE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss) -+#endif -+ -+#if (LZO_OPT_UNALIGNED64) -+#define LZO_MEMOPS_GET_NE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) -+#endif -+ -+__lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv) -+{ -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY2(dd, &vv); -+#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_memops_TU2p d = (lzo_memops_TU2p) dd; -+ unsigned long v = vv; -+ __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); -+#else -+ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; -+ d[0] = LZO_BYTE((vv ) & 0xff); -+ d[1] = LZO_BYTE((vv >> 8) & 0xff); -+#endif -+} -+#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv) -+#endif -+ -+__lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv) -+{ -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY4(dd, &vv); -+#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_memops_TU4p d = (lzo_memops_TU4p) dd; -+ unsigned long v = vv; -+ __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); -+#else -+ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; -+ d[0] = LZO_BYTE((vv ) & 0xff); -+ d[1] = LZO_BYTE((vv >> 8) & 0xff); -+ d[2] = LZO_BYTE((vv >> 16) & 0xff); -+ d[3] = LZO_BYTE((vv >> 24) & 0xff); -+#endif -+} -+#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv) -+#endif -+ -+__lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv) -+{ -+ LZO_MEMOPS_COPY2(dd, &vv); -+} -+#if (LZO_OPT_UNALIGNED16) -+#define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv) -+#endif -+ -+__lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv) -+{ -+ LZO_MEMOPS_COPY4(dd, &vv); -+} -+#if (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv) -+#endif -+ -+#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+static void __attribute__((__unused__)) -+#else -+__lzo_static_forceinline void -+#endif -+lzo_memops_unused_funcs(void) -+{ -+ LZO_UNUSED_FUNC(lzo_memops_get_le16); -+ LZO_UNUSED_FUNC(lzo_memops_get_le32); -+ LZO_UNUSED_FUNC(lzo_memops_get_ne16); -+ LZO_UNUSED_FUNC(lzo_memops_get_ne32); -+ LZO_UNUSED_FUNC(lzo_memops_put_le16); -+ LZO_UNUSED_FUNC(lzo_memops_put_le32); -+ LZO_UNUSED_FUNC(lzo_memops_put_ne16); -+ LZO_UNUSED_FUNC(lzo_memops_put_ne32); -+ LZO_UNUSED_FUNC(lzo_memops_unused_funcs); -+} -+ -+#endif -+ -+#ifndef UA_SET1 -+#define UA_SET1 LZO_MEMOPS_SET1 -+#endif -+#ifndef UA_SET2 -+#define UA_SET2 LZO_MEMOPS_SET2 -+#endif -+#ifndef UA_SET3 -+#define UA_SET3 LZO_MEMOPS_SET3 -+#endif -+#ifndef UA_SET4 -+#define UA_SET4 LZO_MEMOPS_SET4 -+#endif -+#ifndef UA_MOVE1 -+#define UA_MOVE1 LZO_MEMOPS_MOVE1 -+#endif -+#ifndef UA_MOVE2 -+#define UA_MOVE2 LZO_MEMOPS_MOVE2 -+#endif -+#ifndef UA_MOVE3 -+#define UA_MOVE3 LZO_MEMOPS_MOVE3 -+#endif -+#ifndef UA_MOVE4 -+#define UA_MOVE4 LZO_MEMOPS_MOVE4 -+#endif -+#ifndef UA_MOVE8 -+#define UA_MOVE8 LZO_MEMOPS_MOVE8 -+#endif -+#ifndef UA_COPY1 -+#define UA_COPY1 LZO_MEMOPS_COPY1 -+#endif -+#ifndef UA_COPY2 -+#define UA_COPY2 LZO_MEMOPS_COPY2 -+#endif -+#ifndef UA_COPY3 -+#define UA_COPY3 LZO_MEMOPS_COPY3 -+#endif -+#ifndef UA_COPY4 -+#define UA_COPY4 LZO_MEMOPS_COPY4 -+#endif -+#ifndef UA_COPY8 -+#define UA_COPY8 LZO_MEMOPS_COPY8 -+#endif -+#ifndef UA_COPYN -+#define UA_COPYN LZO_MEMOPS_COPYN -+#endif -+#ifndef UA_COPYN_X -+#define UA_COPYN_X LZO_MEMOPS_COPYN -+#endif -+#ifndef UA_GET_LE16 -+#define UA_GET_LE16 LZO_MEMOPS_GET_LE16 -+#endif -+#ifndef UA_GET_LE32 -+#define UA_GET_LE32 LZO_MEMOPS_GET_LE32 -+#endif -+#ifdef LZO_MEMOPS_GET_LE64 -+#ifndef UA_GET_LE64 -+#define UA_GET_LE64 LZO_MEMOPS_GET_LE64 -+#endif -+#endif -+#ifndef UA_GET_NE16 -+#define UA_GET_NE16 LZO_MEMOPS_GET_NE16 -+#endif -+#ifndef UA_GET_NE32 -+#define UA_GET_NE32 LZO_MEMOPS_GET_NE32 -+#endif -+#ifdef LZO_MEMOPS_GET_NE64 -+#ifndef UA_GET_NE64 -+#define UA_GET_NE64 LZO_MEMOPS_GET_NE64 -+#endif -+#endif -+#ifndef UA_PUT_LE16 -+#define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16 -+#endif -+#ifndef UA_PUT_LE32 -+#define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32 -+#endif -+#ifndef UA_PUT_NE16 -+#define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16 -+#endif -+#ifndef UA_PUT_NE32 -+#define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32 - #endif - - #define MEMCPY8_DS(dest,src,len) \ -@@ -2195,25 +3782,10 @@ LZO_EXTERN(const lzo_bytep) lzo_copyright(void); - extern "C" { - #endif - --#if !defined(lzo_uintptr_t) --# if (__LZO_MMODEL_HUGE) --# define lzo_uintptr_t unsigned long --# else --# define lzo_uintptr_t acc_uintptr_t --# ifdef __ACC_INTPTR_T_IS_POINTER --# define __LZO_UINTPTR_T_IS_POINTER 1 --# endif --# endif --#endif -- - #if (LZO_ARCH_I086) --#define PTR(a) ((lzo_bytep) (a)) --#define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) --#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) -+#error "LZO_ARCH_I086 is unsupported" - #elif (LZO_MM_PVP) --#define PTR(a) ((lzo_bytep) (a)) --#define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) --#define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) -+#error "LZO_MM_PVP is unsupported" - #else - #define PTR(a) ((lzo_uintptr_t) (a)) - #define PTR_LINEAR(a) PTR(a) -@@ -2243,24 +3815,28 @@ typedef union - unsigned long a_ulong; - lzo_int a_lzo_int; - lzo_uint a_lzo_uint; -- lzo_int32 a_lzo_int32; -- lzo_uint32 a_lzo_uint32; --#if defined(LZO_UINT64_MAX) -- lzo_int64 a_lzo_int64; -- lzo_uint64 a_lzo_uint64; -+ lzo_xint a_lzo_xint; -+ lzo_int16_t a_lzo_int16_t; -+ lzo_uint16_t a_lzo_uint16_t; -+ lzo_int32_t a_lzo_int32_t; -+ lzo_uint32_t a_lzo_uint32_t; -+#if defined(lzo_uint64_t) -+ lzo_int64_t a_lzo_int64_t; -+ lzo_uint64_t a_lzo_uint64_t; - #endif -+ size_t a_size_t; - ptrdiff_t a_ptrdiff_t; - lzo_uintptr_t a_lzo_uintptr_t; -- lzo_voidp a_lzo_voidp; - void * a_void_p; -- lzo_bytep a_lzo_bytep; -- lzo_bytepp a_lzo_bytepp; -- lzo_uintp a_lzo_uintp; -- lzo_uint * a_lzo_uint_p; -- lzo_uint32p a_lzo_uint32p; -- lzo_uint32 * a_lzo_uint32_p; -- unsigned char * a_uchar_p; - char * a_char_p; -+ unsigned char * a_uchar_p; -+ const void * a_c_void_p; -+ const char * a_c_char_p; -+ const unsigned char * a_c_uchar_p; -+ lzo_voidp a_lzo_voidp; -+ lzo_bytep a_lzo_bytep; -+ const lzo_voidp a_c_lzo_voidp; -+ const lzo_bytep a_c_lzo_bytep; - } - lzo_full_align_t; - -@@ -2276,18 +3852,14 @@ lzo_full_align_t; - - #ifndef LZO_DICT_USE_PTR - #define LZO_DICT_USE_PTR 1 --#if 0 && (LZO_ARCH_I086) --# undef LZO_DICT_USE_PTR --# define LZO_DICT_USE_PTR 0 --#endif - #endif - - #if (LZO_DICT_USE_PTR) - # define lzo_dict_t const lzo_bytep --# define lzo_dict_p lzo_dict_t __LZO_MMODEL * -+# define lzo_dict_p lzo_dict_t * - #else - # define lzo_dict_t lzo_uint --# define lzo_dict_p lzo_dict_t __LZO_MMODEL * -+# define lzo_dict_p lzo_dict_t * - #endif - - #endif -@@ -2300,10 +3872,9 @@ __lzo_ptr_linear(const lzo_voidp ptr) - lzo_uintptr_t p; - - #if (LZO_ARCH_I086) -- p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr)); -+#error "LZO_ARCH_I086 is unsupported" - #elif (LZO_MM_PVP) -- p = (lzo_uintptr_t) (ptr); -- p = (p << 3) | (p >> 61); -+#error "LZO_MM_PVP is unsupported" - #else - p = (lzo_uintptr_t) PTR_LINEAR(ptr); - #endif -@@ -2314,9 +3885,8 @@ __lzo_ptr_linear(const lzo_voidp ptr) - LZO_PUBLIC(unsigned) - __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) - { --#if defined(__LZO_UINTPTR_T_IS_POINTER) -- size_t n = (size_t) ptr; -- n = (((n + size - 1) / size) * size) - n; -+#if (__LZO_UINTPTR_T_IS_POINTER) -+#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" - #else - lzo_uintptr_t p, n; - p = __lzo_ptr_linear(ptr); -@@ -2342,7 +3912,7 @@ static const char __lzo_copyright[] = - #else - "\r\n\n" - "LZO data compression library.\n" -- "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n" -+ "$Copyright: LZO Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\n" - "\n" - "http://www.oberhumer.com $\n\n" - "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" -@@ -2352,11 +3922,7 @@ static const char __lzo_copyright[] = - LZO_PUBLIC(const lzo_bytep) - lzo_copyright(void) - { --#if (LZO_OS_DOS16 && LZO_CC_TURBOC) -- return (lzo_voidp) __lzo_copyright; --#else - return (const lzo_bytep) __lzo_copyright; --#endif - } - - LZO_PUBLIC(unsigned) -@@ -2393,16 +3959,16 @@ _lzo_version_date(void) - #define LZO_NMAX 5552 - - #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 --#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); --#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); --#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); --#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); -+#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1) -+#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2) -+#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4) -+#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8) - --LZO_PUBLIC(lzo_uint32) --lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) -+LZO_PUBLIC(lzo_uint32_t) -+lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len) - { -- lzo_uint32 s1 = adler & 0xffff; -- lzo_uint32 s2 = (adler >> 16) & 0xffff; -+ lzo_uint32_t s1 = adler & 0xffff; -+ lzo_uint32_t s2 = (adler >> 16) & 0xffff; - unsigned k; - - if (buf == NULL) -@@ -2459,8 +4025,8 @@ lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) - LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP) -- const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2; -+ const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2); - if __lzo_likely(len > 0) do - { - int d = *p1 - *p2; -@@ -2476,8 +4042,8 @@ LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo - LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY) -- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; -+ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); - if (!(len > 0) || p1 == p2) - return dest; - do -@@ -2491,8 +4057,8 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src - LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE) -- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; -+ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); - if (!(len > 0) || p1 == p2) - return dest; - if (p1 < p2) -@@ -2514,16 +4080,17 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p sr - return memmove(dest, src, len); - #endif - } --LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) -+LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET) -- lzo_hbyte_p p = (lzo_hbyte_p) s; -+ lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s); -+ unsigned char c = LZO_ITRUNC(unsigned char, cc); - if __lzo_likely(len > 0) do -- *p++ = (unsigned char) c; -+ *p++ = c; - while __lzo_likely(--len > 0); - return s; - #else -- return memset(s, c, len); -+ return memset(s, cc, len); - #endif - } - #undef LZOLIB_PUBLIC -@@ -2532,105 +4099,28 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) - - #if !defined(__LZO_IN_MINILZO) - --#define ACC_WANT_ACC_CHK_CH 1 --#undef ACCCHK_ASSERT -+#define LZO_WANT_ACC_CHK_CH 1 -+#undef LZOCHK_ASSERT - -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) -- -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32) -- ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) -- ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4) --#if defined(LZO_UINT64_MAX) -- ACCCHK_ASSERT(sizeof(lzo_uint64) == 8) -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64) -+ LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) -+ LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) -+#if !(__LZO_UINTPTR_T_IS_POINTER) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) - #endif -+ LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) - --#if !defined(__LZO_UINTPTR_T_IS_POINTER) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) - #endif -- ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) -- -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) -- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32)) -- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint)) -- ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint)) -+#undef LZOCHK_ASSERT - -+union lzo_config_check_union { -+ lzo_uint a[2]; -+ unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))]; -+#if defined(lzo_uint64_t) -+ lzo_uint64_t c[2]; - #endif --#undef ACCCHK_ASSERT -- --#if 0 --#define WANT_lzo_bitops_clz32 1 --#define WANT_lzo_bitops_clz64 1 --#endif --#define WANT_lzo_bitops_ctz32 1 --#define WANT_lzo_bitops_ctz64 1 -- --#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) --#include --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 --#pragma intrinsic(_BitScanReverse) --static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanReverse(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz32 lzo_bitops_clz32 --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 --#pragma intrinsic(_BitScanReverse64) --static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanReverse64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz64 lzo_bitops_clz64 --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#pragma intrinsic(_BitScanForward) --static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanForward(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz32 lzo_bitops_ctz32 --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#pragma intrinsic(_BitScanForward64) --static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanForward64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz64 lzo_bitops_ctz64 --#endif -- --#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) --#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) --#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) --#endif --#endif -+}; - - #if 0 - #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off))) -@@ -2644,73 +4134,101 @@ static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off) - LZO_PUBLIC(int) - _lzo_config_check(void) - { -- lzo_bool r = 1; -- union { -- lzo_xint a[2]; unsigned char b[2*LZO_MAX(8,sizeof(lzo_xint))]; --#if defined(LZO_UNALIGNED_OK_8) -- lzo_uint64 c[2]; -+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul)) -+# if 0 -+ volatile -+# endif - #endif -- unsigned short x[2]; lzo_uint32 y[2]; lzo_uint z[2]; -- } u; -+ union lzo_config_check_union u; - lzo_voidp p; -+ unsigned r = 1; - - u.a[0] = u.a[1] = 0; - p = u2p(&u, 0); - r &= ((* (lzo_bytep) p) == 0); --#if !defined(LZO_CFG_NO_CONFIG_CHECK) --#if defined(LZO_ABI_BIG_ENDIAN) -+#if !(LZO_CFG_NO_CONFIG_CHECK) -+#if (LZO_ABI_BIG_ENDIAN) - u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128; - p = u2p(&u, 0); - r &= ((* (lzo_uintp) p) == 128); - #endif --#if defined(LZO_ABI_LITTLE_ENDIAN) -+#if (LZO_ABI_LITTLE_ENDIAN) - u.a[0] = u.a[1] = 0; u.b[0] = 128; - p = u2p(&u, 0); - r &= ((* (lzo_uintp) p) == 128); - #endif --#if defined(LZO_UNALIGNED_OK_2) - u.a[0] = u.a[1] = 0; -- u.b[0] = 1; u.b[sizeof(unsigned short) + 1] = 2; -+ u.b[0] = 1; u.b[3] = 2; - p = u2p(&u, 1); -- r &= ((* (lzo_ushortp) p) == 0); -+ r &= UA_GET_NE16(p) == 0; -+ r &= UA_GET_LE16(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE16(p) == 128; -+ u.b[2] = 129; -+ r &= UA_GET_LE16(p) == LZO_UINT16_C(0x8180); -+#if (LZO_ABI_BIG_ENDIAN) -+ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8081); -+#endif -+#if (LZO_ABI_LITTLE_ENDIAN) -+ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180); - #endif --#if defined(LZO_UNALIGNED_OK_4) - u.a[0] = u.a[1] = 0; -- u.b[0] = 3; u.b[sizeof(lzo_uint32) + 1] = 4; -+ u.b[0] = 3; u.b[5] = 4; - p = u2p(&u, 1); -- r &= ((* (lzo_uint32p) p) == 0); -+ r &= UA_GET_NE32(p) == 0; -+ r &= UA_GET_LE32(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE32(p) == 128; -+ u.b[2] = 129; u.b[3] = 130; u.b[4] = 131; -+ r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180); -+#if (LZO_ABI_BIG_ENDIAN) -+ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283); -+#endif -+#if (LZO_ABI_LITTLE_ENDIAN) -+ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x83828180); - #endif --#if defined(LZO_UNALIGNED_OK_8) -+#if defined(UA_GET_NE64) - u.c[0] = u.c[1] = 0; -- u.b[0] = 5; u.b[sizeof(lzo_uint64) + 1] = 6; -+ u.b[0] = 5; u.b[9] = 6; - p = u2p(&u, 1); -- r &= ((* (lzo_uint64p) p) == 0); -+ u.c[0] = u.c[1] = 0; -+ r &= UA_GET_NE64(p) == 0; -+#if defined(UA_GET_LE64) -+ r &= UA_GET_LE64(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE64(p) == 128; -+#endif - #endif --#if defined(lzo_bitops_clz32) -- { unsigned i; lzo_uint32 v = 1; -- for (i = 0; i < 31; i++, v <<= 1) -- r &= lzo_bitops_clz32(v) == 31 - i; -- } -+#if defined(lzo_bitops_ctlz32) -+ { unsigned i = 0; lzo_uint32_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_ctlz32(v) == 31 - i; -+ r &= lzo_bitops_ctlz32_func(v) == 31 - i; -+ }} - #endif --#if defined(lzo_bitops_clz64) -- { unsigned i; lzo_uint64 v = 1; -- for (i = 0; i < 63; i++, v <<= 1) -- r &= lzo_bitops_clz64(v) == 63 - i; -- } -+#if defined(lzo_bitops_ctlz64) -+ { unsigned i = 0; lzo_uint64_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_ctlz64(v) == 63 - i; -+ r &= lzo_bitops_ctlz64_func(v) == 63 - i; -+ }} - #endif --#if defined(lzo_bitops_ctz32) -- { unsigned i; lzo_uint32 v = 1; -- for (i = 0; i < 31; i++, v <<= 1) -- r &= lzo_bitops_ctz32(v) == i; -- } -+#if defined(lzo_bitops_cttz32) -+ { unsigned i = 0; lzo_uint32_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_cttz32(v) == i; -+ r &= lzo_bitops_cttz32_func(v) == i; -+ }} - #endif --#if defined(lzo_bitops_ctz64) -- { unsigned i; lzo_uint64 v = 1; -- for (i = 0; i < 63; i++, v <<= 1) -- r &= lzo_bitops_ctz64(v) == i; -- } -+#if defined(lzo_bitops_cttz64) -+ { unsigned i = 0; lzo_uint64_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_cttz64(v) == i; -+ r &= lzo_bitops_cttz64_func(v) == i; -+ }} - #endif - #endif -+ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); - - return r == 1 ? LZO_E_OK : LZO_E_ERROR; - } -@@ -2724,11 +4242,11 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, - #if defined(__LZO_IN_MINILZO) - #elif (LZO_CC_MSC && ((_MSC_VER) < 700)) - #else --#define ACC_WANT_ACC_CHK_CH 1 --#undef ACCCHK_ASSERT --#define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) -+#define LZO_WANT_ACC_CHK_CH 1 -+#undef LZOCHK_ASSERT -+#define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) - #endif --#undef ACCCHK_ASSERT -+#undef LZOCHK_ASSERT - - if (v == 0) - return LZO_E_ERROR; -@@ -2736,7 +4254,7 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, - r = (s1 == -1 || s1 == (int) sizeof(short)) && - (s2 == -1 || s2 == (int) sizeof(int)) && - (s3 == -1 || s3 == (int) sizeof(long)) && -- (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && -+ (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) && - (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && - (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && - (s7 == -1 || s7 == (int) sizeof(char *)) && -@@ -2779,11 +4297,11 @@ int __far __pascal LibMain ( int a, short b, short c, long d ) - - #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) - --#if 1 && defined(UA_GET32) -+#if 1 && defined(UA_GET_LE32) - #undef LZO_DICT_USE_PTR - #define LZO_DICT_USE_PTR 0 - #undef lzo_dict_t --#define lzo_dict_t unsigned short -+#define lzo_dict_t lzo_uint16_t - #endif - - #define LZO_NEED_DICT_H 1 -@@ -3088,77 +4606,7 @@ DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) - #endif - - #if 1 && defined(DO_COMPRESS) && !defined(do_compress) --# define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core) --#endif -- --#if defined(UA_GET64) --# define WANT_lzo_bitops_ctz64 1 --#elif defined(UA_GET32) --# define WANT_lzo_bitops_ctz32 1 --#endif -- --#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) --#include --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 --#pragma intrinsic(_BitScanReverse) --static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanReverse(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz32 lzo_bitops_clz32 --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 --#pragma intrinsic(_BitScanReverse64) --static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanReverse64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz64 lzo_bitops_clz64 --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#pragma intrinsic(_BitScanForward) --static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanForward(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz32 lzo_bitops_ctz32 --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#pragma intrinsic(_BitScanForward64) --static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanForward64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz64 lzo_bitops_ctz64 --#endif -- --#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) --#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) --#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) --#endif -+# define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core) - #endif - - static __lzo_noinline lzo_uint -@@ -3166,7 +4614,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, - lzo_bytep out, lzo_uintp out_len, - lzo_uint ti, lzo_voidp wrkmem) - { -- register const lzo_bytep ip; -+ const lzo_bytep ip; - lzo_bytep op; - const lzo_bytep const in_end = in + in_len; - const lzo_bytep const ip_end = in + in_len - 20; -@@ -3175,7 +4623,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, - - op = out; - ip = in; -- ii = ip - ti; -+ ii = ip; - - ip += ti < 4 ? 4 - ti : 0; - for (;;) -@@ -3205,8 +4653,8 @@ next: - goto literal; - - try_match: --#if defined(UA_GET32) -- if (UA_GET32(m_pos) != UA_GET32(ip)) -+#if (LZO_OPT_UNALIGNED32) -+ if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip)) - #else - if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3]) - #endif -@@ -3221,49 +4669,43 @@ literal: - lzo_uint m_off; - lzo_uint m_len; - { -- lzo_uint32 dv; -+ lzo_uint32_t dv; - lzo_uint dindex; - literal: - ip += 1 + ((ip - ii) >> 5); - next: - if __lzo_unlikely(ip >= ip_end) - break; -- dv = UA_GET32(ip); -+ dv = UA_GET_LE32(ip); - dindex = DINDEX(dv,ip); - GINDEX(m_off,m_pos,in+dict,dindex,in); - UPDATE_I(dict,0,dindex,ip,in); -- if __lzo_unlikely(dv != UA_GET32(m_pos)) -+ if __lzo_unlikely(dv != UA_GET_LE32(m_pos)) - goto literal; - } - #endif - -+ ii -= ti; ti = 0; - { -- register lzo_uint t = pd(ip,ii); -+ lzo_uint t = pd(ip,ii); - if (t != 0) - { - if (t <= 3) - { -- op[-2] |= LZO_BYTE(t); --#if defined(UA_COPY32) -- UA_COPY32(op, ii); -+ op[-2] = LZO_BYTE(op[-2] | t); -+#if (LZO_OPT_UNALIGNED32) -+ UA_COPY4(op, ii); - op += t; - #else - { do *op++ = *ii++; while (--t > 0); } - #endif - } --#if defined(UA_COPY32) || defined(UA_COPY64) -+#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) - else if (t <= 16) - { - *op++ = LZO_BYTE(t - 3); --#if defined(UA_COPY64) -- UA_COPY64(op, ii); -- UA_COPY64(op+8, ii+8); --#else -- UA_COPY32(op, ii); -- UA_COPY32(op+4, ii+4); -- UA_COPY32(op+8, ii+8); -- UA_COPY32(op+12, ii+12); --#endif -+ UA_COPY8(op, ii); -+ UA_COPY8(op+8, ii+8); - op += t; - } - #endif -@@ -3273,31 +4715,21 @@ next: - *op++ = LZO_BYTE(t - 3); - else - { -- register lzo_uint tt = t - 18; -+ lzo_uint tt = t - 18; - *op++ = 0; - while __lzo_unlikely(tt > 255) - { - tt -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - assert(tt > 0); - *op++ = LZO_BYTE(tt); - } --#if defined(UA_COPY32) || defined(UA_COPY64) -+#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) - do { --#if defined(UA_COPY64) -- UA_COPY64(op, ii); -- UA_COPY64(op+8, ii+8); --#else -- UA_COPY32(op, ii); -- UA_COPY32(op+4, ii+4); -- UA_COPY32(op+8, ii+8); -- UA_COPY32(op+12, ii+12); --#endif -+ UA_COPY8(op, ii); -+ UA_COPY8(op+8, ii+8); - op += 16; ii += 16; t -= 16; - } while (t >= 16); if (t > 0) - #endif -@@ -3307,19 +4739,26 @@ next: - } - m_len = 4; - { --#if defined(UA_GET64) -- lzo_uint64 v; -- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); -+#if (LZO_OPT_UNALIGNED64) -+ lzo_uint64_t v; -+ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); - if __lzo_unlikely(v == 0) { - do { - m_len += 8; -- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); -+ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (v == 0); - } --#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64) -- m_len += lzo_bitops_ctz64(v) / CHAR_BIT; -+#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64) -+ m_len += lzo_bitops_ctlz64(v) / CHAR_BIT; -+#elif (LZO_ABI_BIG_ENDIAN) -+ if ((v >> (64 - CHAR_BIT)) == 0) do { -+ v <<= CHAR_BIT; -+ m_len += 1; -+ } while ((v >> (64 - CHAR_BIT)) == 0); -+#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64) -+ m_len += lzo_bitops_cttz64(v) / CHAR_BIT; - #elif (LZO_ABI_LITTLE_ENDIAN) - if ((v & UCHAR_MAX) == 0) do { - v >>= CHAR_BIT; -@@ -3330,19 +4769,30 @@ next: - m_len += 1; - } while (ip[m_len] == m_pos[m_len]); - #endif --#elif defined(UA_GET32) -- lzo_uint32 v; -- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); -+#elif (LZO_OPT_UNALIGNED32) -+ lzo_uint32_t v; -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); - if __lzo_unlikely(v == 0) { - do { - m_len += 4; -- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); -+ if (v != 0) -+ break; -+ m_len += 4; -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (v == 0); - } --#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32) -- m_len += lzo_bitops_ctz32(v) / CHAR_BIT; -+#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32) -+ m_len += lzo_bitops_ctlz32(v) / CHAR_BIT; -+#elif (LZO_ABI_BIG_ENDIAN) -+ if ((v >> (32 - CHAR_BIT)) == 0) do { -+ v <<= CHAR_BIT; -+ m_len += 1; -+ } while ((v >> (32 - CHAR_BIT)) == 0); -+#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32) -+ m_len += lzo_bitops_cttz32(v) / CHAR_BIT; - #elif (LZO_ABI_LITTLE_ENDIAN) - if ((v & UCHAR_MAX) == 0) do { - v >>= CHAR_BIT; -@@ -3357,6 +4807,27 @@ next: - if __lzo_unlikely(ip[m_len] == m_pos[m_len]) { - do { - m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (ip[m_len] == m_pos[m_len]); -@@ -3390,11 +4861,8 @@ m_len_done: - while __lzo_unlikely(m_len > 255) - { - m_len -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - *op++ = LZO_BYTE(m_len); - } -@@ -3413,11 +4881,8 @@ m_len_done: - while __lzo_unlikely(m_len > 255) - { - m_len -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - *op++ = LZO_BYTE(m_len); - } -@@ -3428,7 +4893,7 @@ m_len_done: - } - - *out_len = pd(op, out); -- return pd(in_end,ii); -+ return pd(in_end,ii-ti); - } - - LZO_PUBLIC(int) -@@ -3468,7 +4933,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - if (op == out && t <= 238) - *op++ = LZO_BYTE(17 + t); - else if (t <= 3) -- op[-2] |= LZO_BYTE(t); -+ op[-2] = LZO_BYTE(op[-2] | t); - else if (t <= 18) - *op++ = LZO_BYTE(t - 3); - else -@@ -3479,17 +4944,14 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - while (tt > 255) - { - tt -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - assert(tt > 0); - *op++ = LZO_BYTE(tt); - } -- do *op++ = *ii++; while (--t > 0); -+ UA_COPYN(op, ii, t); -+ op += t; - } - - *op++ = M4_MARKER | 1; -@@ -3526,10 +4988,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - - #undef TEST_IP - #undef TEST_OP -+#undef TEST_IP_AND_TEST_OP - #undef TEST_LB - #undef TEST_LBO - #undef NEED_IP - #undef NEED_OP -+#undef TEST_IV -+#undef TEST_OV - #undef HAVE_TEST_IP - #undef HAVE_TEST_OP - #undef HAVE_NEED_IP -@@ -3544,6 +5009,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # if (LZO_TEST_OVERRUN_INPUT >= 2) - # define NEED_IP(x) \ - if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -+# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun - # endif - #endif - -@@ -3555,12 +5021,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # undef TEST_OP - # define NEED_OP(x) \ - if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -+# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun - # endif - #endif - - #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) --# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun --# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun -+# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun -+# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun - #else - # define TEST_LB(m_pos) ((void) 0) - # define TEST_LBO(m_pos,o) ((void) 0) -@@ -3581,15 +5048,27 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # define TEST_OP 1 - #endif - -+#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) -+#elif defined(HAVE_TEST_IP) -+# define TEST_IP_AND_TEST_OP TEST_IP -+#elif defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP TEST_OP -+#else -+# define TEST_IP_AND_TEST_OP 1 -+#endif -+ - #if defined(NEED_IP) - # define HAVE_NEED_IP 1 - #else - # define NEED_IP(x) ((void) 0) -+# define TEST_IV(x) ((void) 0) - #endif - #if defined(NEED_OP) - # define HAVE_NEED_OP 1 - #else - # define NEED_OP(x) ((void) 0) -+# define TEST_OV(x) ((void) 0) - #endif - - #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) -@@ -3606,14 +5085,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - lzo_voidp wrkmem ) - #endif - { -- register lzo_bytep op; -- register const lzo_bytep ip; -- register lzo_uint t; -+ lzo_bytep op; -+ const lzo_bytep ip; -+ lzo_uint t; - #if defined(COPY_DICT) - lzo_uint m_off; - const lzo_bytep dict_end; - #else -- register const lzo_bytep m_pos; -+ const lzo_bytep m_pos; - #endif - - const lzo_bytep const ip_end = in + in_len; -@@ -3648,43 +5127,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - op = out; - ip = in; - -+ NEED_IP(1); - if (*ip > 17) - { - t = *ip++ - 17; - if (t < 4) - goto match_next; -- assert(t > 0); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); NEED_OP(t); NEED_IP(t+3); - do *op++ = *ip++; while (--t > 0); - goto first_literal_run; - } - -- while (TEST_IP && TEST_OP) -+ for (;;) - { -+ NEED_IP(3); - t = *ip++; - if (t >= 16) - goto match; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_IV(t); - NEED_IP(1); - } - t += 15 + *ip++; - } -- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - t += 3; - if (t >= 8) do - { -- UA_COPY64(op,ip); -+ UA_COPY8(op,ip); - op += 8; ip += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } - if (t > 0) -@@ -3692,19 +5173,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - *op++ = *ip++; - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - } --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (PTR_ALIGNED2_4(op,ip)) - { - #endif -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; - if (--t > 0) - { - if (t >= 4) - { - do { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *ip++; while (--t > 0); -@@ -3712,12 +5193,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - else - do *op++ = *ip++; while (--t > 0); - } --#if !defined(LZO_UNALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - } - else - #endif - #endif --#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) -+#if !(LZO_OPT_UNALIGNED32) - { - *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do *op++ = *ip++; while (--t > 0); -@@ -3753,7 +5234,7 @@ first_literal_run: - #endif - goto match_done; - -- do { -+ for (;;) { - match: - if (t >= 64) - { -@@ -3813,14 +5294,15 @@ match: - t &= 31; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 31 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -3836,9 +5318,9 @@ match: - m_pos = op - off; - last_m_off = off; - } --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) - m_pos = op - 1; -- m_pos -= UA_GET16(ip) >> 2; -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos = op - 1; - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -@@ -3857,14 +5339,15 @@ match: - t &= 7; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 7 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -3882,8 +5365,8 @@ match: - #else - #if defined(LZO1Z) - m_pos -= (ip[0] << 6) + (ip[1] >> 2); --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -- m_pos -= UA_GET16(ip) >> 2; -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos -= (ip[0] >> 2) + (ip[1] << 6); - #endif -@@ -3931,18 +5414,18 @@ match: - #else - - TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - if (op - m_pos >= 8) - { - t += (3 - 1); - if (t >= 8) do - { -- UA_COPY64(op,m_pos); -+ UA_COPY8(op,m_pos); - op += 8; m_pos += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } - if (t > 0) -@@ -3952,8 +5435,8 @@ match: - } - } - else --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) - { - assert((op - m_pos) >= 4); -@@ -3961,10 +5444,10 @@ match: - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) - { - #endif -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4 - (3 - 1); - do { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *m_pos++; while (--t > 0); -@@ -3989,7 +5472,7 @@ match_done: - break; - - match_next: -- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); - #if 0 - do *op++ = *ip++; while (--t > 0); - #else -@@ -3997,16 +5480,10 @@ match_next: - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - #endif - t = *ip++; -- } while (TEST_IP && TEST_OP); -+ } - } - --#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) -- *out_len = pd(op, out); -- return LZO_E_EOF_NOT_FOUND; --#endif -- - eof_found: -- assert(t == 1); - *out_len = pd(op, out); - return (ip == ip_end ? LZO_E_OK : - (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); -@@ -4052,10 +5529,13 @@ lookbehind_overrun: - - #undef TEST_IP - #undef TEST_OP -+#undef TEST_IP_AND_TEST_OP - #undef TEST_LB - #undef TEST_LBO - #undef NEED_IP - #undef NEED_OP -+#undef TEST_IV -+#undef TEST_OV - #undef HAVE_TEST_IP - #undef HAVE_TEST_OP - #undef HAVE_NEED_IP -@@ -4070,6 +5550,7 @@ lookbehind_overrun: - # if (LZO_TEST_OVERRUN_INPUT >= 2) - # define NEED_IP(x) \ - if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -+# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun - # endif - #endif - -@@ -4081,12 +5562,13 @@ lookbehind_overrun: - # undef TEST_OP - # define NEED_OP(x) \ - if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -+# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun - # endif - #endif - - #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) --# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun --# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun -+# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun -+# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun - #else - # define TEST_LB(m_pos) ((void) 0) - # define TEST_LBO(m_pos,o) ((void) 0) -@@ -4107,15 +5589,27 @@ lookbehind_overrun: - # define TEST_OP 1 - #endif - -+#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) -+#elif defined(HAVE_TEST_IP) -+# define TEST_IP_AND_TEST_OP TEST_IP -+#elif defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP TEST_OP -+#else -+# define TEST_IP_AND_TEST_OP 1 -+#endif -+ - #if defined(NEED_IP) - # define HAVE_NEED_IP 1 - #else - # define NEED_IP(x) ((void) 0) -+# define TEST_IV(x) ((void) 0) - #endif - #if defined(NEED_OP) - # define HAVE_NEED_OP 1 - #else - # define NEED_OP(x) ((void) 0) -+# define TEST_OV(x) ((void) 0) - #endif - - #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) -@@ -4132,14 +5626,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - lzo_voidp wrkmem ) - #endif - { -- register lzo_bytep op; -- register const lzo_bytep ip; -- register lzo_uint t; -+ lzo_bytep op; -+ const lzo_bytep ip; -+ lzo_uint t; - #if defined(COPY_DICT) - lzo_uint m_off; - const lzo_bytep dict_end; - #else -- register const lzo_bytep m_pos; -+ const lzo_bytep m_pos; - #endif - - const lzo_bytep const ip_end = in + in_len; -@@ -4174,43 +5668,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - op = out; - ip = in; - -+ NEED_IP(1); - if (*ip > 17) - { - t = *ip++ - 17; - if (t < 4) - goto match_next; -- assert(t > 0); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); NEED_OP(t); NEED_IP(t+3); - do *op++ = *ip++; while (--t > 0); - goto first_literal_run; - } - -- while (TEST_IP && TEST_OP) -+ for (;;) - { -+ NEED_IP(3); - t = *ip++; - if (t >= 16) - goto match; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_IV(t); - NEED_IP(1); - } - t += 15 + *ip++; - } -- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - t += 3; - if (t >= 8) do - { -- UA_COPY64(op,ip); -+ UA_COPY8(op,ip); - op += 8; ip += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } - if (t > 0) -@@ -4218,19 +5714,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - *op++ = *ip++; - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - } --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (PTR_ALIGNED2_4(op,ip)) - { - #endif -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; - if (--t > 0) - { - if (t >= 4) - { - do { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *ip++; while (--t > 0); -@@ -4238,12 +5734,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - else - do *op++ = *ip++; while (--t > 0); - } --#if !defined(LZO_UNALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - } - else - #endif - #endif --#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) -+#if !(LZO_OPT_UNALIGNED32) - { - *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do *op++ = *ip++; while (--t > 0); -@@ -4279,7 +5775,7 @@ first_literal_run: - #endif - goto match_done; - -- do { -+ for (;;) { - match: - if (t >= 64) - { -@@ -4339,14 +5835,15 @@ match: - t &= 31; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 31 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -4362,9 +5859,9 @@ match: - m_pos = op - off; - last_m_off = off; - } --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) - m_pos = op - 1; -- m_pos -= UA_GET16(ip) >> 2; -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos = op - 1; - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -@@ -4383,14 +5880,15 @@ match: - t &= 7; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 7 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -4408,8 +5906,8 @@ match: - #else - #if defined(LZO1Z) - m_pos -= (ip[0] << 6) + (ip[1] >> 2); --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -- m_pos -= UA_GET16(ip) >> 2; -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos -= (ip[0] >> 2) + (ip[1] << 6); - #endif -@@ -4457,18 +5955,18 @@ match: - #else - - TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - if (op - m_pos >= 8) - { - t += (3 - 1); - if (t >= 8) do - { -- UA_COPY64(op,m_pos); -+ UA_COPY8(op,m_pos); - op += 8; m_pos += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } - if (t > 0) -@@ -4478,8 +5976,8 @@ match: - } - } - else --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) - { - assert((op - m_pos) >= 4); -@@ -4487,10 +5985,10 @@ match: - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) - { - #endif -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4 - (3 - 1); - do { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *m_pos++; while (--t > 0); -@@ -4515,7 +6013,7 @@ match_done: - break; - - match_next: -- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); - #if 0 - do *op++ = *ip++; while (--t > 0); - #else -@@ -4523,16 +6021,10 @@ match_next: - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - #endif - t = *ip++; -- } while (TEST_IP && TEST_OP); -+ } - } - --#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) -- *out_len = pd(op, out); -- return LZO_E_EOF_NOT_FOUND; --#endif -- - eof_found: -- assert(t == 1); - *out_len = pd(op, out); - return (ip == ip_end ? LZO_E_OK : - (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); -@@ -4559,4 +6051,3 @@ lookbehind_overrun: - #endif - - /***** End of minilzo.c *****/ -- -diff --git a/grub-core/lib/minilzo/lzoconf.h b/grub-core/lib/minilzo/lzoconf.h -index 1d0fe14fcda..61be29c5dc2 100644 ---- a/grub-core/lib/minilzo/lzoconf.h -+++ b/grub-core/lib/minilzo/lzoconf.h -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -44,9 +29,9 @@ - #ifndef __LZOCONF_H_INCLUDED - #define __LZOCONF_H_INCLUDED 1 - --#define LZO_VERSION 0x2050 --#define LZO_VERSION_STRING "2.05" --#define LZO_VERSION_DATE "Apr 23 2011" -+#define LZO_VERSION 0x2080 -+#define LZO_VERSION_STRING "2.08" -+#define LZO_VERSION_DATE "Jun 29 2014" - - /* internal Autoconf configuration file - only used when building LZO */ - #if defined(LZO_HAVE_CONFIG_H) -@@ -63,7 +48,7 @@ - #if !defined(CHAR_BIT) || (CHAR_BIT != 8) - # error "invalid CHAR_BIT" - #endif --#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) -+#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) - # error "check your compiler installation" - #endif - #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) -@@ -85,14 +70,6 @@ extern "C" { - // some core defines - ************************************************************************/ - --#if !defined(LZO_UINT32_C) --# if (UINT_MAX < LZO_0xffffffffL) --# define LZO_UINT32_C(c) c ## UL --# else --# define LZO_UINT32_C(c) ((c) + 0U) --# endif --#endif -- - /* memory checkers */ - #if !defined(__LZO_CHECKER) - # if defined(__BOUNDS_CHECKING_ON) -@@ -111,28 +88,31 @@ extern "C" { - // integral and pointer types - ************************************************************************/ - --/* lzo_uint should match size_t */ -+/* lzo_uint must match size_t */ - #if !defined(LZO_UINT_MAX) --# if defined(LZO_ABI_LLP64) /* WIN64 */ --# if defined(LZO_OS_WIN64) -+# if (LZO_ABI_LLP64) -+# if (LZO_OS_WIN64) - typedef unsigned __int64 lzo_uint; - typedef __int64 lzo_int; - # else -- typedef unsigned long long lzo_uint; -- typedef long long lzo_int; -+ typedef lzo_ullong_t lzo_uint; -+ typedef lzo_llong_t lzo_int; - # endif -+# define LZO_SIZEOF_LZO_UINT 8 - # define LZO_UINT_MAX 0xffffffffffffffffull - # define LZO_INT_MAX 9223372036854775807LL - # define LZO_INT_MIN (-1LL - LZO_INT_MAX) --# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ -+# elif (LZO_ABI_IP32L64) /* MIPS R5900 */ - typedef unsigned int lzo_uint; - typedef int lzo_int; -+# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT - # define LZO_UINT_MAX UINT_MAX - # define LZO_INT_MAX INT_MAX - # define LZO_INT_MIN INT_MIN - # elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint; - typedef long lzo_int; -+# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG - # define LZO_UINT_MAX ULONG_MAX - # define LZO_INT_MAX LONG_MAX - # define LZO_INT_MIN LONG_MIN -@@ -141,63 +121,22 @@ extern "C" { - # endif - #endif - --/* Integral types with 32 bits or more. */ --#if !defined(LZO_UINT32_MAX) --# if (UINT_MAX >= LZO_0xffffffffL) -- typedef unsigned int lzo_uint32; -- typedef int lzo_int32; --# define LZO_UINT32_MAX UINT_MAX --# define LZO_INT32_MAX INT_MAX --# define LZO_INT32_MIN INT_MIN --# elif (ULONG_MAX >= LZO_0xffffffffL) -- typedef unsigned long lzo_uint32; -- typedef long lzo_int32; --# define LZO_UINT32_MAX ULONG_MAX --# define LZO_INT32_MAX LONG_MAX --# define LZO_INT32_MIN LONG_MIN --# else --# error "lzo_uint32" --# endif --#endif -- --/* Integral types with exactly 64 bits. */ --#if !defined(LZO_UINT64_MAX) --# if (LZO_UINT_MAX >= LZO_0xffffffffL) --# if ((((LZO_UINT_MAX) >> 31) >> 31) == 3) --# define lzo_uint64 lzo_uint --# define lzo_int64 lzo_int --# define LZO_UINT64_MAX LZO_UINT_MAX --# define LZO_INT64_MAX LZO_INT_MAX --# define LZO_INT64_MIN LZO_INT_MIN --# endif --# elif (ULONG_MAX >= LZO_0xffffffffL) --# if ((((ULONG_MAX) >> 31) >> 31) == 3) -- typedef unsigned long lzo_uint64; -- typedef long lzo_int64; --# define LZO_UINT64_MAX ULONG_MAX --# define LZO_INT64_MAX LONG_MAX --# define LZO_INT64_MIN LONG_MIN --# endif --# endif --#endif -- --/* The larger type of lzo_uint and lzo_uint32. */ --#if (LZO_UINT_MAX >= LZO_UINT32_MAX) -+/* The larger type of lzo_uint and lzo_uint32_t. */ -+#if (LZO_SIZEOF_LZO_UINT >= 4) - # define lzo_xint lzo_uint - #else --# define lzo_xint lzo_uint32 -+# define lzo_xint lzo_uint32_t - #endif - --/* Memory model that allows to access memory at offsets of lzo_uint. */ --#if !defined(__LZO_MMODEL) --# if (LZO_UINT_MAX <= UINT_MAX) --# define __LZO_MMODEL /*empty*/ --# elif defined(LZO_HAVE_MM_HUGE_PTR) --# define __LZO_MMODEL_HUGE 1 --# define __LZO_MMODEL __huge --# else --# define __LZO_MMODEL /*empty*/ --# endif -+typedef int lzo_bool; -+ -+/* sanity checks */ -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t)) -+ -+#ifndef __LZO_MMODEL -+#define __LZO_MMODEL /*empty*/ - #endif - - /* no typedef here because of const-pointer issues */ -@@ -206,21 +145,52 @@ extern "C" { - #define lzo_voidp void __LZO_MMODEL * - #define lzo_shortp short __LZO_MMODEL * - #define lzo_ushortp unsigned short __LZO_MMODEL * --#define lzo_uint32p lzo_uint32 __LZO_MMODEL * --#define lzo_int32p lzo_int32 __LZO_MMODEL * --#if defined(LZO_UINT64_MAX) --#define lzo_uint64p lzo_uint64 __LZO_MMODEL * --#define lzo_int64p lzo_int64 __LZO_MMODEL * --#endif --#define lzo_uintp lzo_uint __LZO_MMODEL * - #define lzo_intp lzo_int __LZO_MMODEL * -+#define lzo_uintp lzo_uint __LZO_MMODEL * - #define lzo_xintp lzo_xint __LZO_MMODEL * - #define lzo_voidpp lzo_voidp __LZO_MMODEL * - #define lzo_bytepp lzo_bytep __LZO_MMODEL * --/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ --#define lzo_byte unsigned char __LZO_MMODEL - --typedef int lzo_bool; -+#define lzo_int8_tp lzo_int8_t __LZO_MMODEL * -+#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL * -+#define lzo_int16_tp lzo_int16_t __LZO_MMODEL * -+#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL * -+#define lzo_int32_tp lzo_int32_t __LZO_MMODEL * -+#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL * -+#if defined(lzo_int64_t) -+#define lzo_int64_tp lzo_int64_t __LZO_MMODEL * -+#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL * -+#endif -+ -+/* Older LZO versions used to support ancient systems and memory models -+ * like 16-bit MSDOS with __huge pointers and Cray PVP, but these -+ * obsolete configurations are not supported any longer. -+ */ -+#if defined(__LZO_MMODEL_HUGE) -+#error "__LZO_MMODEL_HUGE is unsupported" -+#endif -+#if (LZO_MM_PVP) -+#error "LZO_MM_PVP is unsupported" -+#endif -+#if (LZO_SIZEOF_INT < 4) -+#error "LZO_SIZEOF_INT < 4 is unsupported" -+#endif -+#if (__LZO_UINTPTR_T_IS_POINTER) -+#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4) -+/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should -+ * work but have not received much testing lately, so be strict here. -+ */ -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) - - - /*********************************************************************** -@@ -315,7 +285,7 @@ struct lzo_callback_t - /* a progress indicator callback function (set to 0 to disable) */ - lzo_progress_func_t nprogress; - -- /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress -+ /* INFO: the first parameter "self" of the nalloc/nfree/nprogress - * callbacks points back to this struct, so you are free to store - * some extra info in the following variables. */ - lzo_voidp user1; -@@ -343,6 +313,9 @@ struct lzo_callback_t - #define LZO_E_INPUT_NOT_CONSUMED (-8) - #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ - #define LZO_E_INVALID_ARGUMENT (-10) -+#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */ -+#define LZO_E_OUTPUT_NOT_CONSUMED (-12) -+#define LZO_E_INTERNAL_ERROR (-99) - - - #ifndef lzo_sizeof_dict_t -@@ -356,7 +329,7 @@ struct lzo_callback_t - * compiler's view of various types are consistent. - */ - #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ -- (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ -+ (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ - (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ - (int)sizeof(lzo_callback_t)) - LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); -@@ -379,18 +352,22 @@ LZO_EXTERN(lzo_voidp) - lzo_memset(lzo_voidp buf, int c, lzo_uint len); - - /* checksum functions */ --LZO_EXTERN(lzo_uint32) -- lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); --LZO_EXTERN(lzo_uint32) -- lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); --LZO_EXTERN(const lzo_uint32p) -+LZO_EXTERN(lzo_uint32_t) -+ lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); -+LZO_EXTERN(lzo_uint32_t) -+ lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); -+LZO_EXTERN(const lzo_uint32_tp) - lzo_get_crc32_table(void); - - /* misc. */ - LZO_EXTERN(int) _lzo_config_check(void); --typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; --typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; --typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t; -+typedef union { -+ lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; -+ void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; -+#if defined(lzo_int64_t) -+ lzo_uint64_t a10; -+#endif -+} lzo_align_t; - - /* align a char pointer on a boundary that is a multiple of 'size' */ - LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); -@@ -399,9 +376,30 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); - - - /*********************************************************************** --// deprecated macros - only for backward compatibility with LZO v1.xx -+// deprecated macros - only for backward compatibility - ************************************************************************/ - -+/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ -+#define lzo_byte unsigned char -+/* deprecated type names */ -+#define lzo_int32 lzo_int32_t -+#define lzo_uint32 lzo_uint32_t -+#define lzo_int32p lzo_int32_t __LZO_MMODEL * -+#define lzo_uint32p lzo_uint32_t __LZO_MMODEL * -+#define LZO_INT32_MAX LZO_INT32_C(2147483647) -+#define LZO_UINT32_MAX LZO_UINT32_C(4294967295) -+#if defined(lzo_int64_t) -+#define lzo_int64 lzo_int64_t -+#define lzo_uint64 lzo_uint64_t -+#define lzo_int64p lzo_int64_t __LZO_MMODEL * -+#define lzo_uint64p lzo_uint64_t __LZO_MMODEL * -+#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807) -+#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615) -+#endif -+/* deprecated types */ -+typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u; -+typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u; -+ - #if defined(LZO_CFG_COMPAT) - - #define __LZOCONF_H 1 -@@ -443,4 +441,4 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); - #endif /* already included */ - - --/* vim:set ts=4 et: */ -+/* vim:set ts=4 sw=4 et: */ -diff --git a/grub-core/lib/minilzo/lzodefs.h b/grub-core/lib/minilzo/lzodefs.h -index 0e40e332a8d..f4ae9487ebe 100644 ---- a/grub-core/lib/minilzo/lzodefs.h -+++ b/grub-core/lib/minilzo/lzodefs.h -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -47,12 +32,6 @@ - #if defined(__CYGWIN32__) && !defined(__CYGWIN__) - # define __CYGWIN__ __CYGWIN32__ - #endif --#if defined(__IBMCPP__) && !defined(__IBMC__) --# define __IBMC__ __IBMCPP__ --#endif --#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) --# define __INTEL_COMPILER __ICL --#endif - #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) - # define _ALL_SOURCE 1 - #endif -@@ -61,19 +40,30 @@ - # define __LONG_MAX__ 9223372036854775807L - # endif - #endif --#if defined(__INTEL_COMPILER) && defined(__linux__) -+#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) -+#if defined(__ARMCC_VERSION) -+# pragma diag_suppress 193 -+#elif defined(__clang__) && defined(__clang_minor__) -+# pragma clang diagnostic ignored "-Wundef" -+#elif defined(__INTEL_COMPILER) - # pragma warning(disable: 193) --#endif --#if defined(__KEIL__) && defined(__C166__) -+#elif defined(__KEIL__) && defined(__C166__) - # pragma warning disable = 322 --#elif 0 && defined(__C251__) --# pragma warning disable = 322 --#endif --#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) --# if (_MSC_VER >= 1300) -+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) -+# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) -+# pragma GCC diagnostic ignored "-Wundef" -+# endif -+#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -+# if ((_MSC_VER-0) >= 1300) - # pragma warning(disable: 4668) - # endif - #endif -+#endif -+#if 0 && defined(__POCC__) && defined(_WIN32) -+# if (__POCC__ >= 400) -+# pragma warn(disable: 2216) -+# endif -+#endif - #if 0 && defined(__WATCOMC__) - # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) - # pragma warning 203 9 -@@ -82,13 +72,29 @@ - #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) - # pragma option -h - #endif -+#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) -+#ifndef _CRT_NONSTDC_NO_DEPRECATE -+#define _CRT_NONSTDC_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_NONSTDC_NO_WARNINGS -+#define _CRT_NONSTDC_NO_WARNINGS 1 -+#endif -+#ifndef _CRT_SECURE_NO_DEPRECATE -+#define _CRT_SECURE_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_SECURE_NO_WARNINGS -+#define _CRT_SECURE_NO_WARNINGS 1 -+#endif -+#endif - #if 0 --#define LZO_0xffffL 0xfffful --#define LZO_0xffffffffL 0xfffffffful -+#define LZO_0xffffUL 0xfffful -+#define LZO_0xffffffffUL 0xfffffffful - #else --#define LZO_0xffffL 65535ul --#define LZO_0xffffffffL 4294967295ul -+#define LZO_0xffffUL 65535ul -+#define LZO_0xffffffffUL 4294967295ul - #endif -+#define LZO_0xffffL LZO_0xffffUL -+#define LZO_0xffffffffL LZO_0xffffffffUL - #if (LZO_0xffffL == LZO_0xffffffffL) - # error "your preprocessor is broken 1" - #endif -@@ -103,6 +109,13 @@ - # error "your preprocessor is broken 4" - #endif - #endif -+#if defined(__COUNTER__) -+# ifndef LZO_CFG_USE_COUNTER -+# define LZO_CFG_USE_COUNTER 1 -+# endif -+#else -+# undef LZO_CFG_USE_COUNTER -+#endif - #if (UINT_MAX == LZO_0xffffL) - #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) - # if !defined(MSDOS) -@@ -233,14 +246,31 @@ - #endif - #define LZO_PP_STRINGIZE(x) #x - #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) -+#define LZO_PP_CONCAT0() /*empty*/ -+#define LZO_PP_CONCAT1(a) a - #define LZO_PP_CONCAT2(a,b) a ## b - #define LZO_PP_CONCAT3(a,b,c) a ## b ## c - #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g -+#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() -+#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) - #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) - #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) - #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) - #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) -+#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) -+#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) -+#define LZO_PP_EMPTY /*empty*/ -+#define LZO_PP_EMPTY0() /*empty*/ -+#define LZO_PP_EMPTY1(a) /*empty*/ -+#define LZO_PP_EMPTY2(a,b) /*empty*/ -+#define LZO_PP_EMPTY3(a,b,c) /*empty*/ -+#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ -+#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ -+#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ -+#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ - #if 1 - #define LZO_CPP_STRINGIZE(x) #x - #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) -@@ -248,12 +278,16 @@ - #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c - #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g - #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) - #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) - #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) - #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) -+#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) -+#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) - #endif --#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) -+#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) - #if 1 && defined(__cplusplus) - # if !defined(__STDC_CONSTANT_MACROS) - # define __STDC_CONSTANT_MACROS 1 -@@ -263,9 +297,13 @@ - # endif - #endif - #if defined(__cplusplus) --# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C_BEGIN extern "C" { -+# define LZO_EXTERN_C_END } - #else --# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C_BEGIN /*empty*/ -+# define LZO_EXTERN_C_END /*empty*/ - #endif - #if !defined(__LZO_OS_OVERRIDE) - #if (LZO_OS_FREESTANDING) -@@ -366,12 +404,12 @@ - #elif defined(__VMS) - # define LZO_OS_VMS 1 - # define LZO_INFO_OS "vms" --#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PS2 1 - # define LZO_INFO_OS "console" - # define LZO_INFO_OS_CONSOLE "ps2" --#elif (defined(__mips__) && defined(__psp__)) -+#elif defined(__mips__) && defined(__psp__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PSP 1 - # define LZO_INFO_OS "console" -@@ -399,9 +437,18 @@ - # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) - # define LZO_OS_POSIX_LINUX 1 - # define LZO_INFO_OS_POSIX "linux" --# elif defined(__APPLE__) || defined(__MACOS__) --# define LZO_OS_POSIX_MACOSX 1 --# define LZO_INFO_OS_POSIX "macosx" -+# elif defined(__APPLE__) && defined(__MACH__) -+# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) -+# define LZO_OS_POSIX_DARWIN 1040 -+# define LZO_INFO_OS_POSIX "darwin_iphone" -+# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) -+# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -+# define LZO_INFO_OS_POSIX "darwin" -+# else -+# define LZO_OS_POSIX_DARWIN 1 -+# define LZO_INFO_OS_POSIX "darwin" -+# endif -+# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN - # elif defined(__minix__) || defined(__minix) - # define LZO_OS_POSIX_MINIX 1 - # define LZO_INFO_OS_POSIX "minix" -@@ -436,18 +483,18 @@ - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) - # if (UINT_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) -@@ -463,59 +510,65 @@ - # define LZO_INFO_CC "sdcc" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) - #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) --# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) -+# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) - # define LZO_INFO_CC "Pathscale C" - # define LZO_INFO_CCVER __PATHSCALE__ --#elif defined(__INTEL_COMPILER) --# define LZO_CC_INTELC 1 -+# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# endif -+#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) -+# define LZO_CC_INTELC __INTEL_COMPILER - # define LZO_INFO_CC "Intel C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) --# if defined(_WIN32) || defined(_WIN64) --# define LZO_CC_SYNTAX_MSC 1 --# else --# define LZO_CC_SYNTAX_GNUC 1 -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_INTELC_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif - #elif defined(__POCC__) && defined(_WIN32) - # define LZO_CC_PELLESC 1 - # define LZO_INFO_CC "Pelles C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) --#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) - # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) --# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) -+# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) - # else --# define LZO_CC_CLANG_CLANG 0x010000L -+# define LZO_CC_CLANG 0x010000L -+# endif -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_CLANG_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif --# define LZO_CC_CLANG LZO_CC_CLANG_GNUC - # define LZO_INFO_CC "clang" - # define LZO_INFO_CCVER __VERSION__ - #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif - # define LZO_CC_LLVM LZO_CC_LLVM_GNUC - # define LZO_INFO_CC "llvm-gcc" - # define LZO_INFO_CCVER __VERSION__ --#elif defined(__GNUC__) && defined(__VERSION__) --# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) --# elif defined(__GNUC_MINOR__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) --# else --# define LZO_CC_GNUC (__GNUC__ * 0x10000L) --# endif --# define LZO_INFO_CC "gcc" --# define LZO_INFO_CCVER __VERSION__ - #elif defined(__ACK__) && defined(_ACK) - # define LZO_CC_ACK 1 - # define LZO_INFO_CC "Amsterdam Compiler Kit C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) - #elif defined(__AZTEC_C__) - # define LZO_CC_AZTECC 1 - # define LZO_INFO_CC "Aztec C" -@@ -540,10 +593,23 @@ - # define LZO_CC_DECC 1 - # define LZO_INFO_CC "DEC C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) -+#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) -+# define LZO_CC_GHS 1 -+# define LZO_INFO_CC "Green Hills C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_GHS_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# endif - #elif defined(__HIGHC__) - # define LZO_CC_HIGHC 1 - # define LZO_INFO_CC "MetaWare High C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) -+# define LZO_CC_HPACC __HP_aCC -+# define LZO_INFO_CC "HP aCC" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) - #elif defined(__IAR_SYSTEMS_ICC__) - # define LZO_CC_IARC 1 - # define LZO_INFO_CC "IAR C" -@@ -552,10 +618,14 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(__IBMC__) --# define LZO_CC_IBMC 1 -+#elif defined(__IBMC__) && ((__IBMC__-0) > 0) -+# define LZO_CC_IBMC __IBMC__ - # define LZO_INFO_CC "IBM C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) -+#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) -+# define LZO_CC_IBMC __IBMCPP__ -+# define LZO_INFO_CC "IBM C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) - #elif defined(__KEIL__) && defined(__C166__) - # define LZO_CC_KEILC 1 - # define LZO_INFO_CC "Keil C" -@@ -572,16 +642,8 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(_MSC_VER) --# define LZO_CC_MSC 1 --# define LZO_INFO_CC "Microsoft C" --# if defined(_MSC_FULL_VER) --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) --# else --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) --# endif --#elif defined(__MWERKS__) --# define LZO_CC_MWERKS 1 -+#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) -+# define LZO_CC_MWERKS __MWERKS__ - # define LZO_INFO_CC "Metrowerks C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) - #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) -@@ -592,6 +654,15 @@ - # define LZO_CC_PACIFICC 1 - # define LZO_INFO_CC "Pacific C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) -+#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) -+# if defined(__PGIC_PATCHLEVEL__) -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) -+# else -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" -+# endif -+# define LZO_INFO_CC "Portland Group PGI C" - #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) - # define LZO_CC_PGI 1 - # define LZO_INFO_CC "Portland Group PGI C" -@@ -606,7 +677,7 @@ - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) - #elif defined(__SUNPRO_C) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_C)+0 > 0) -+# if ((__SUNPRO_C-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_C - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) - # else -@@ -615,7 +686,7 @@ - # endif - #elif defined(__SUNPRO_CC) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_CC)+0 > 0) -+# if ((__SUNPRO_CC-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_CC - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) - # else -@@ -641,16 +712,46 @@ - #elif defined(__ZTC__) - # define LZO_CC_ZORTECHC 1 - # define LZO_INFO_CC "Zortech C" --# if (__ZTC__ == 0x310) -+# if ((__ZTC__-0) == 0x310) - # define LZO_INFO_CCVER "0x310" - # else - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) - # endif -+#elif defined(__GNUC__) && defined(__VERSION__) -+# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# elif defined(__GNUC_MINOR__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) -+# else -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L) -+# endif -+# define LZO_INFO_CC "gcc" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_MSC _MSC_VER -+# define LZO_INFO_CC "Microsoft C" -+# if defined(_MSC_FULL_VER) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) -+# else -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) -+# endif - #else - # define LZO_CC_UNKNOWN 1 - # define LZO_INFO_CC "unknown" - # define LZO_INFO_CCVER "unknown" - #endif -+#if (LZO_CC_GNUC) && defined(__OPEN64__) -+# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) -+# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) -+# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC -+# endif -+#endif -+#if (LZO_CC_GNUC) && defined(__PCC__) -+# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) -+# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) -+# define LZO_CC_PCC_GNUC LZO_CC_GNUC -+# endif -+#endif - #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) - # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" - #endif -@@ -668,8 +769,10 @@ - # define LZO_INFO_ARCH "generic" - #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086 1 --# define LZO_ARCH_IA16 1 - # define LZO_INFO_ARCH "i086" -+#elif defined(__aarch64__) -+# define LZO_ARCH_ARM64 1 -+# define LZO_INFO_ARCH "arm64" - #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) - # define LZO_ARCH_ALPHA 1 - # define LZO_INFO_ARCH "alpha" -@@ -685,10 +788,10 @@ - # define LZO_INFO_ARCH "arm_thumb" - #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) - # define LZO_ARCH_ARM 1 --# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) -+# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) - # define LZO_ARCH_ARM_THUMB 1 - # define LZO_INFO_ARCH "arm_thumb" --# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) -+# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) - # define LZO_INFO_ARCH "arm" - # else - # define LZO_INFO_ARCH "arm" -@@ -806,53 +909,147 @@ - # error "FIXME - missing define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) --# error "FIXME - missing WIN32 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) --# error "FIXME - missing WIN64 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" - #endif - #if (LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #endif --#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) --# error "this should not happen" -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) -+# define LZO_ARCH_X64 1 -+#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_AMD64 1 - #endif --#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) --# error "this should not happen" -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) -+# define LZO_ARCH_AARCH64 1 -+#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_ARM64 1 -+#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) -+# define LZO_ARCH_X86 1 -+#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_I386 1 -+#endif -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) -+# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ARCH_I086) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_ARCH_I386) - # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif --#if !defined(__LZO_MM_OVERRIDE) -+#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# if !defined(LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSE2__) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_SSSE3) -+# if (LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSSE3__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# elif defined(_MSC_VER) && defined(__AVX__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_SSE4_2) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__SSE4_2__) -+# define LZO_TARGET_FEATURE_SSE4_2 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__AVX__) -+# define LZO_TARGET_FEATURE_AVX 1 -+# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX2) -+# if (LZO_TARGET_FEATURE_AVX) -+# if defined(__AVX2__) -+# define LZO_TARGET_FEATURE_AVX2 1 -+# endif -+# endif -+# endif -+#endif -+#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if (LZO_ARCH_ARM) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if defined(__ARM_NEON__) -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if 1 -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif -+# endif -+#endif -+#if 0 -+#elif !defined(__LZO_MM_OVERRIDE) - #if (LZO_ARCH_I086) - #if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif - #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) - # define LZO_MM_TINY 1 -@@ -879,7 +1076,7 @@ - #elif (LZO_CC_ZORTECHC && defined(__VCM__)) - # define LZO_MM_LARGE 1 - #else --# error "unknown memory model" -+# error "unknown LZO_ARCH_I086 memory model" - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - #define LZO_HAVE_MM_HUGE_PTR 1 -@@ -902,10 +1099,10 @@ - #endif - #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) - # if (LZO_OS_DOS16) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # elif (LZO_CC_ZORTECHC) - # else --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #ifdef __cplusplus -@@ -937,7 +1134,7 @@ extern "C" { - #endif - #elif (LZO_ARCH_C166) - #if !defined(__MODEL__) --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 1) -@@ -951,11 +1148,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #endif - #elif (LZO_ARCH_MCS251) - #if !defined(__MODEL__) --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -967,11 +1164,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #endif - #elif (LZO_ARCH_MCS51) - #if !defined(__MODEL__) --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #elif ((__MODEL__) == 1) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -983,7 +1180,7 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #endif - #elif (LZO_ARCH_CRAY_PVP) - # define LZO_MM_PVP 1 -@@ -1010,35 +1207,818 @@ extern "C" { - # error "unknown memory model" - #endif - #endif -+#if !defined(__lzo_gnuc_extension__) -+#if (LZO_CC_GNUC >= 0x020800ul) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_gnuc_extension__ __extension__ -+#else -+#endif -+#endif -+#if !defined(__lzo_gnuc_extension__) -+# define __lzo_gnuc_extension__ /*empty*/ -+#endif -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 -+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# else -+# define LZO_CFG_USE_NEW_STYLE_CASTS 1 -+# endif -+#endif -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+#endif -+#if !defined(__cplusplus) -+# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# undef LZO_CFG_USE_NEW_STYLE_CASTS -+# endif -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+#endif -+#if !defined(LZO_REINTERPRET_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) -+# endif -+#endif -+#if !defined(LZO_REINTERPRET_CAST) -+# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) -+#endif -+#if !defined(LZO_STATIC_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_STATIC_CAST(t,e) (static_cast (e)) -+# endif -+#endif -+#if !defined(LZO_STATIC_CAST) -+# define LZO_STATIC_CAST(t,e) ((t) (e)) -+#endif -+#if !defined(LZO_STATIC_CAST2) -+# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) -+#endif -+#if !defined(LZO_UNCONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) -+# endif -+#endif -+#if !defined(LZO_UNCONST_CAST) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) -+#endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif -+#endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) -+#endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) -+# endif -+#endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) -+#endif -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif -+#endif -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) -+#endif -+#if !defined(LZO_PCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_PCAST(t,e) ((t) (e)) -+# endif -+#endif -+#if !defined(LZO_PCAST) -+# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) -+#endif -+#if !defined(LZO_CCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_CCAST(t,e) ((t) (e)) -+# endif -+#endif -+#if !defined(LZO_CCAST) -+# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) -+#endif -+#if !defined(LZO_ICONV) -+# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(LZO_ICAST) -+# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(LZO_ITRUNC) -+# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) -+#endif -+#if !defined(__lzo_cte) -+# if (LZO_CC_MSC || LZO_CC_WATCOMC) -+# define __lzo_cte(e) ((void)0,(e)) -+# elif 1 -+# define __lzo_cte(e) ((void)0,(e)) -+# endif -+#endif -+#if !defined(__lzo_cte) -+# define __lzo_cte(e) (e) -+#endif -+#if !defined(LZO_BLOCK_BEGIN) -+# define LZO_BLOCK_BEGIN do { -+# define LZO_BLOCK_END } while __lzo_cte(0) -+#endif -+#if !defined(LZO_UNUSED) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNUSED(var) ((void) var) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_KEILC) -+# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} -+# elif (LZO_CC_PACIFICC) -+# define LZO_UNUSED(var) ((void) sizeof(var)) -+# elif (LZO_CC_WATCOMC) && defined(__cplusplus) -+# define LZO_UNUSED(var) ((void) var) -+# else -+# define LZO_UNUSED(var) ((void) &var) -+# endif -+#endif -+#if !defined(LZO_UNUSED_FUNC) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED_FUNC(func) ((void) func) -+# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_CLANG || LZO_CC_LLVM) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_MSC) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_KEILC || LZO_CC_PELLESC) -+# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} -+# else -+# define LZO_UNUSED_FUNC(func) ((void) func) -+# endif -+#endif -+#if !defined(LZO_UNUSED_LABEL) -+# if (LZO_CC_CLANG >= 0x020800ul) -+# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) -+# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -+# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l -+# else -+# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l -+# endif -+#endif -+#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -+# if 0 -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var -+# elif 0 && (LZO_CC_GNUC) -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -+# else -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -+# endif -+#endif -+#if !defined(__lzo_inline) -+#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) -+#elif defined(__cplusplus) -+# define __lzo_inline inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_inline inline -+#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) -+# define __lzo_inline __inline -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_DMC) -+# define __lzo_inline __inline -+#elif (LZO_CC_GHS) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_INTELC) -+# define __lzo_inline __inline -+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) -+# define __lzo_inline __inline -+#elif (LZO_CC_MSC && (_MSC_VER >= 900)) -+# define __lzo_inline __inline -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_inline __inline__ -+#endif -+#endif -+#if defined(__lzo_inline) -+# ifndef __lzo_HAVE_inline -+# define __lzo_HAVE_inline 1 -+# endif -+#else -+# define __lzo_inline /*empty*/ -+#endif -+#if !defined(__lzo_forceinline) -+#if (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_forceinline __forceinline -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_forceinline __forceinline -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#endif -+#endif -+#if defined(__lzo_forceinline) -+# ifndef __lzo_HAVE_forceinline -+# define __lzo_HAVE_forceinline 1 -+# endif -+#else -+# define __lzo_forceinline __lzo_inline -+#endif -+#if !defined(__lzo_noinline) -+#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) -+# define __lzo_noinline __attribute__((__noinline__,__used__)) -+#elif (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noinline __declspec(noinline) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_noinline __declspec(noinline) -+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) -+# if defined(__cplusplus) -+# else -+# define __lzo_noinline __declspec(noinline) -+# endif -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_noinline __attribute__((__noinline__)) -+#endif -+#endif -+#if defined(__lzo_noinline) -+# ifndef __lzo_HAVE_noinline -+# define __lzo_HAVE_noinline 1 -+# endif -+#else -+# define __lzo_noinline /*empty*/ -+#endif -+#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if !defined(__lzo_static_inline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline -+#endif -+#endif -+#if !defined(__lzo_static_inline) -+# define __lzo_static_inline static __lzo_inline -+#endif -+#if !defined(__lzo_static_forceinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline -+#endif -+#endif -+#if !defined(__lzo_static_forceinline) -+# define __lzo_static_forceinline static __lzo_forceinline -+#endif -+#if !defined(__lzo_static_noinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline -+#endif -+#endif -+#if !defined(__lzo_static_noinline) -+# define __lzo_static_noinline static __lzo_noinline -+#endif -+#if !defined(__lzo_c99_extern_inline) -+#if defined(__GNUC_GNU_INLINE__) -+# define __lzo_c99_extern_inline __lzo_inline -+#elif defined(__GNUC_STDC_INLINE__) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#endif -+#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) -+# define __lzo_c99_extern_inline __lzo_inline -+#endif -+#endif -+#if defined(__lzo_c99_extern_inline) -+# ifndef __lzo_HAVE_c99_extern_inline -+# define __lzo_HAVE_c99_extern_inline 1 -+# endif -+#else -+# define __lzo_c99_extern_inline /*empty*/ -+#endif -+#if !defined(__lzo_may_alias) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_CLANG >= 0x020900ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#endif -+#endif -+#if defined(__lzo_may_alias) -+# ifndef __lzo_HAVE_may_alias -+# define __lzo_HAVE_may_alias 1 -+# endif -+#else -+# define __lzo_may_alias /*empty*/ -+#endif -+#if !defined(__lzo_noreturn) -+#if (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#endif -+#endif -+#if defined(__lzo_noreturn) -+# ifndef __lzo_HAVE_noreturn -+# define __lzo_HAVE_noreturn 1 -+# endif -+#else -+# define __lzo_noreturn /*empty*/ -+#endif -+#if !defined(__lzo_nothrow) -+#if (LZO_CC_GNUC >= 0x030300ul) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) -+#endif -+#endif -+#if defined(__lzo_nothrow) -+# ifndef __lzo_HAVE_nothrow -+# define __lzo_HAVE_nothrow 1 -+# endif -+#else -+# define __lzo_nothrow /*empty*/ -+#endif -+#if !defined(__lzo_restrict) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_IBMC >= 1210) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) -+# define __lzo_restrict __restrict -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_restrict __restrict__ -+#endif -+#endif -+#if defined(__lzo_restrict) -+# ifndef __lzo_HAVE_restrict -+# define __lzo_HAVE_restrict 1 -+# endif -+#else -+# define __lzo_restrict /*empty*/ -+#endif -+#if !defined(__lzo_alignof) -+#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_GHS) && !defined(__cplusplus) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_alignof(e) __alignof(e) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_alignof(e) __alignof__(e) -+#endif -+#endif -+#if defined(__lzo_alignof) -+# ifndef __lzo_HAVE_alignof -+# define __lzo_HAVE_alignof 1 -+# endif -+#endif -+#if !defined(__lzo_struct_packed) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { -+# define __lzo_struct_packed_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_struct_packed(s) _Packed struct s { -+# define __lzo_struct_packed_end() }; -+#endif -+#endif -+#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) -+# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) -+#endif -+#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) -+# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() -+#endif -+#if !defined(__lzo_byte_struct) -+#if defined(__lzo_struct_packed) -+# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() -+# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() -+#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); -+# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); -+#endif -+#endif -+#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) -+# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) -+#endif -+#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) -+#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) -+#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_CILLY || LZO_CC_PCC) -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_align16(s) struct __declspec(align(16)) s { -+# define __lzo_struct_align16_end() }; -+# define __lzo_struct_align32(s) struct __declspec(align(32)) s { -+# define __lzo_struct_align32_end() }; -+# define __lzo_struct_align64(s) struct __declspec(align(64)) s { -+# define __lzo_struct_align64_end() }; -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_struct_align16(s) struct s { -+# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); -+# define __lzo_struct_align32(s) struct s { -+# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); -+# define __lzo_struct_align64(s) struct s { -+# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); -+#endif -+#endif -+#if !defined(__lzo_union_um) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_union_um(s) __pragma(pack(push,1)) union s { -+# define __lzo_union_um_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_union_um(s) _Packed union s { -+# define __lzo_union_um_end() }; -+#endif -+#endif -+#if !defined(__lzo_union_am) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() }; -+#endif -+#if !defined(__lzo_constructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_constructor __attribute__((__constructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_constructor __attribute__((__constructor__)) -+#endif -+#endif -+#if defined(__lzo_constructor) -+# ifndef __lzo_HAVE_constructor -+# define __lzo_HAVE_constructor 1 -+# endif -+#endif -+#if !defined(__lzo_destructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_destructor __attribute__((__destructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_destructor __attribute__((__destructor__)) -+#endif -+#endif -+#if defined(__lzo_destructor) -+# ifndef __lzo_HAVE_destructor -+# define __lzo_HAVE_destructor 1 -+# endif -+#endif -+#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if !defined(__lzo_likely) && !defined(__lzo_unlikely) -+#if (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_IBMC >= 1010) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#endif -+#endif -+#if defined(__lzo_likely) -+# ifndef __lzo_HAVE_likely -+# define __lzo_HAVE_likely 1 -+# endif -+#else -+# define __lzo_likely(e) (e) -+#endif -+#if defined(__lzo_unlikely) -+# ifndef __lzo_HAVE_unlikely -+# define __lzo_HAVE_unlikely 1 -+# endif -+#else -+# define __lzo_unlikely(e) (e) -+#endif -+#if !defined(__lzo_static_unused_void_func) -+# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) -+# else -+# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) -+# endif -+#endif -+#if !defined(__lzo_loop_forever) -+# if (LZO_CC_IBMC) -+# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END -+# else -+# define __lzo_loop_forever() do { ; } while __lzo_cte(1) -+# endif -+#endif -+#if !defined(__lzo_unreachable) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_GNUC >= 0x040500ul) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 -+# define __lzo_unreachable() __builtin_unreachable(); -+#endif -+#endif -+#if defined(__lzo_unreachable) -+# ifndef __lzo_HAVE_unreachable -+# define __lzo_HAVE_unreachable 1 -+# endif -+#else -+# if 0 -+# define __lzo_unreachable() ((void)0); -+# else -+# define __lzo_unreachable() __lzo_loop_forever(); -+# endif -+#endif -+#ifndef __LZO_CTA_NAME -+#if (LZO_CFG_USE_COUNTER) -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) -+#else -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) -+#endif -+#endif -+#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) -+# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END -+# else -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END -+# endif -+#endif -+#if !defined(LZO_COMPILE_TIME_ASSERT) -+# if (LZO_CC_AZTECC) -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} -+# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} -+# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} -+# elif (LZO_CC_GNUC >= 0x040700ul) -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# else -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} -+# endif -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) -+#if defined(__cplusplus) -+extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) -+#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) -+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) -+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -+# define __lzo_cdecl __cdecl -+# define __lzo_cdecl_atexit /*empty*/ -+# define __lzo_cdecl_main __cdecl -+# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -+# define __lzo_cdecl_qsort __pascal -+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -+# define __lzo_cdecl_qsort _stdcall -+# else -+# define __lzo_cdecl_qsort __cdecl -+# endif -+# elif (LZO_CC_WATCOMC) -+# define __lzo_cdecl __cdecl -+# else -+# define __lzo_cdecl __cdecl -+# define __lzo_cdecl_atexit __cdecl -+# define __lzo_cdecl_main __cdecl -+# define __lzo_cdecl_qsort __cdecl -+# endif -+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) -+# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -+# define __lzo_cdecl_sighandler __pascal -+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -+# define __lzo_cdecl_sighandler _stdcall -+# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) -+# define __lzo_cdecl_sighandler __clrcall -+# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) -+# if defined(_DLL) -+# define __lzo_cdecl_sighandler _far _cdecl _loadds -+# elif defined(_MT) -+# define __lzo_cdecl_sighandler _far _cdecl -+# else -+# define __lzo_cdecl_sighandler _cdecl -+# endif -+# else -+# define __lzo_cdecl_sighandler __cdecl -+# endif -+#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) -+# define __lzo_cdecl __cdecl -+#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) -+# define __lzo_cdecl cdecl -+#endif -+#if !defined(__lzo_cdecl) -+# define __lzo_cdecl /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_atexit) -+# define __lzo_cdecl_atexit /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_main) -+# define __lzo_cdecl_main /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_qsort) -+# define __lzo_cdecl_qsort /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_sighandler) -+# define __lzo_cdecl_sighandler /*empty*/ -+#endif -+#if !defined(__lzo_cdecl_va) -+# define __lzo_cdecl_va __lzo_cdecl -+#endif -+#if !(LZO_CFG_NO_WINDOWS_H) -+#if !defined(LZO_HAVE_WINDOWS_H) -+#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) -+# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) -+# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) -+# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) -+# else -+# define LZO_HAVE_WINDOWS_H 1 -+# endif -+#endif -+#endif -+#endif -+#ifndef LZO_SIZEOF_SHORT - #if defined(SIZEOF_SHORT) - # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -+#elif defined(__SIZEOF_SHORT__) -+# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) - #endif -+#endif -+#ifndef LZO_SIZEOF_INT - #if defined(SIZEOF_INT) - # define LZO_SIZEOF_INT (SIZEOF_INT) -+#elif defined(__SIZEOF_INT__) -+# define LZO_SIZEOF_INT (__SIZEOF_INT__) - #endif -+#endif -+#ifndef LZO_SIZEOF_LONG - #if defined(SIZEOF_LONG) - # define LZO_SIZEOF_LONG (SIZEOF_LONG) -+#elif defined(__SIZEOF_LONG__) -+# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) - #endif -+#endif -+#ifndef LZO_SIZEOF_LONG_LONG - #if defined(SIZEOF_LONG_LONG) - # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -+#elif defined(__SIZEOF_LONG_LONG__) -+# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) - #endif -+#endif -+#ifndef LZO_SIZEOF___INT16 - #if defined(SIZEOF___INT16) - # define LZO_SIZEOF___INT16 (SIZEOF___INT16) - #endif -+#endif -+#ifndef LZO_SIZEOF___INT32 - #if defined(SIZEOF___INT32) - # define LZO_SIZEOF___INT32 (SIZEOF___INT32) - #endif -+#endif -+#ifndef LZO_SIZEOF___INT64 - #if defined(SIZEOF___INT64) - # define LZO_SIZEOF___INT64 (SIZEOF___INT64) - #endif -+#endif -+#ifndef LZO_SIZEOF_VOID_P - #if defined(SIZEOF_VOID_P) - # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -+#elif defined(__SIZEOF_POINTER__) -+# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) - #endif -+#endif -+#ifndef LZO_SIZEOF_SIZE_T - #if defined(SIZEOF_SIZE_T) - # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -+#elif defined(__SIZEOF_SIZE_T__) -+# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) - #endif -+#endif -+#ifndef LZO_SIZEOF_PTRDIFF_T - #if defined(SIZEOF_PTRDIFF_T) - # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -+#elif defined(__SIZEOF_PTRDIFF_T__) -+# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) -+#endif - #endif - #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) - #if !defined(LZO_SIZEOF_SHORT) -@@ -1060,6 +2040,7 @@ extern "C" { - # error "LZO_SIZEOF_SHORT" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) - #if !defined(LZO_SIZEOF_INT) - # if (LZO_ARCH_CRAY_PVP) - # define LZO_SIZEOF_INT 8 -@@ -1081,6 +2062,7 @@ extern "C" { - # error "LZO_SIZEOF_INT" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) - #if !defined(LZO_SIZEOF_LONG) - # if (ULONG_MAX == LZO_0xffffffffL) - # define LZO_SIZEOF_LONG 4 -@@ -1090,6 +2072,8 @@ extern "C" { - # define LZO_SIZEOF_LONG 2 - # elif (__LZO_LSR(ULONG_MAX,31) == 1) - # define LZO_SIZEOF_LONG 4 -+# elif (__LZO_LSR(ULONG_MAX,39) == 1) -+# define LZO_SIZEOF_LONG 5 - # elif (__LZO_LSR(ULONG_MAX,63) == 1) - # define LZO_SIZEOF_LONG 8 - # elif (__LZO_LSR(ULONG_MAX,127) == 1) -@@ -1098,11 +2082,12 @@ extern "C" { - # error "LZO_SIZEOF_LONG" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) - #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) - #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) - # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) - # if (LZO_CC_GNUC >= 0x030300ul) --# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) -+# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) - # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG - # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) - # define LZO_SIZEOF_LONG_LONG 4 -@@ -1116,7 +2101,7 @@ extern "C" { - #if (LZO_ARCH_I086 && LZO_CC_DMC) - #elif (LZO_CC_CILLY) && defined(__GNUC__) - # define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define LZO_SIZEOF_LONG_LONG 8 - #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) - # define LZO_SIZEOF_LONG_LONG 8 -@@ -1138,11 +2123,13 @@ extern "C" { - # define LZO_SIZEOF___INT64 8 - #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) - # define LZO_SIZEOF___INT64 8 --#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) -+#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) - # define LZO_SIZEOF___INT64 8 - #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) - # define LZO_SIZEOF_LONG_LONG 8 --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) - # define LZO_SIZEOF_LONG_LONG 8 - #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) - #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -@@ -1155,87 +2142,127 @@ extern "C" { - # undef LZO_SIZEOF_LONG_LONG - # endif - #endif --#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) -+#if (LZO_CFG_NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(__NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(_NO_LONGLONG) - # undef LZO_SIZEOF_LONG_LONG - #endif --#if !defined(LZO_SIZEOF_VOID_P) --#if (LZO_ARCH_I086) --# define __LZO_WORDSIZE 2 --# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) --# define LZO_SIZEOF_VOID_P 2 --# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) --# define LZO_SIZEOF_VOID_P 4 -+#if !defined(LZO_WORDSIZE) -+#if (LZO_ARCH_ALPHA) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AMD64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AVR) -+# define LZO_WORDSIZE 1 -+#elif (LZO_ARCH_H8300) -+# if defined(__NORMAL_MODE__) -+# define LZO_WORDSIZE 4 -+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -+# define LZO_WORDSIZE 4 - # else --# error "LZO_MM" -+# define LZO_WORDSIZE 2 - # endif --#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) --# define __LZO_WORDSIZE 1 -+#elif (LZO_ARCH_I086) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_IA64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_M16C) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_SPU) -+# define LZO_WORDSIZE 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_WORDSIZE 1 -+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+# define LZO_WORDSIZE 8 -+#elif (LZO_OS_OS400 || defined(__OS400__)) -+# define LZO_WORDSIZE 8 -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_WORDSIZE 8 -+#endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 4 -+#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif (LZO_ARCH_AVR) - # define LZO_SIZEOF_VOID_P 2 - #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) - # define LZO_SIZEOF_VOID_P 2 - #elif (LZO_ARCH_H8300) - # if defined(__NORMAL_MODE__) --# define __LZO_WORDSIZE 4 - # define LZO_SIZEOF_VOID_P 2 - # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) --# define __LZO_WORDSIZE 4 - # define LZO_SIZEOF_VOID_P 4 - # else --# define __LZO_WORDSIZE 2 - # define LZO_SIZEOF_VOID_P 2 - # endif - # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) - # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT - # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT - # endif -+#elif (LZO_ARCH_I086) -+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -+# define LZO_SIZEOF_VOID_P 2 -+# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# error "invalid LZO_ARCH_I086 memory model" -+# endif - #elif (LZO_ARCH_M16C) --# define __LZO_WORDSIZE 2 - # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) - # define LZO_SIZEOF_VOID_P 4 - # else - # define LZO_SIZEOF_VOID_P 2 - # endif -+#elif (LZO_ARCH_SPU) -+# define LZO_SIZEOF_VOID_P 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_SIZEOF_VOID_P 2 - #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) --# define __LZO_WORDSIZE 8 - # define LZO_SIZEOF_VOID_P 4 --#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) --# define __LZO_WORDSIZE 8 --# define LZO_SIZEOF_VOID_P 8 --#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - #elif (LZO_OS_OS400 || defined(__OS400__)) --# define __LZO_WORDSIZE LZO_SIZEOF_LONG --# define LZO_SIZEOF_VOID_P 16 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) --# define LZO_SIZEOF_VOID_P 8 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (LZO_ARCH_SPU) --# if 0 --# define __LZO_WORDSIZE 16 --# endif --# define LZO_SIZEOF_VOID_P 4 --#else --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --#endif --#endif --#if !defined(LZO_WORDSIZE) --# if defined(__LZO_WORDSIZE) --# define LZO_WORDSIZE __LZO_WORDSIZE -+# if defined(__LLP64_IFC__) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - # else --# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -+# define LZO_SIZEOF_VOID_P 16 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - # endif -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - #endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) - #if !defined(LZO_SIZEOF_SIZE_T) - #if (LZO_ARCH_I086 || LZO_ARCH_M16C) - # define LZO_SIZEOF_SIZE_T 2 --#else -+#endif -+#endif -+#if !defined(LZO_SIZEOF_SIZE_T) - # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P - #endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) - #endif - #if !defined(LZO_SIZEOF_PTRDIFF_T) - #if (LZO_ARCH_I086) -@@ -1248,11 +2275,18 @@ extern "C" { - # define LZO_SIZEOF_PTRDIFF_T 2 - # endif - # else --# error "LZO_MM" -+# error "invalid LZO_ARCH_I086 memory model" - # endif --#else -+#endif -+#endif -+#if !defined(LZO_SIZEOF_PTRDIFF_T) - # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T - #endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) -+#endif -+#if !defined(LZO_WORDSIZE) -+# define LZO_WORDSIZE LZO_SIZEOF_VOID_P - #endif - #if (LZO_ABI_NEUTRAL_ENDIAN) - # undef LZO_ABI_BIG_ENDIAN -@@ -1264,7 +2298,7 @@ extern "C" { - # define LZO_ABI_LITTLE_ENDIAN 1 - #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) - # define LZO_ABI_LITTLE_ENDIAN 1 --#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) -+#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) - # if (__LITTLE_ENDIAN__ == 1) -@@ -1280,6 +2314,19 @@ extern "C" { - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) - # define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) -+# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) -+# error "unexpected configuration - check your compiler defines" -+# elif defined(__BIG_ENDIAN) -+# define LZO_ABI_BIG_ENDIAN 1 -+# else -+# define LZO_ABI_LITTLE_ENDIAN 1 -+# endif -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 - #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -@@ -1287,7 +2334,7 @@ extern "C" { - #endif - #endif - #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ABI_BIG_ENDIAN) - # define LZO_INFO_ABI_ENDIAN "be" -@@ -1302,6 +2349,9 @@ extern "C" { - #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) - # define LZO_ABI_ILP16 1 - # define LZO_INFO_ABI_PM "ilp16" -+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_LP32 1 -+# define LZO_INFO_ABI_PM "lp32" - #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) - # define LZO_ABI_ILP32 1 - # define LZO_INFO_ABI_PM "ilp32" -@@ -1318,7 +2368,8 @@ extern "C" { - # define LZO_ABI_IP32L64 1 - # define LZO_INFO_ABI_PM "ip32l64" - #endif --#if !defined(__LZO_LIBC_OVERRIDE) -+#if 0 -+#elif !defined(__LZO_LIBC_OVERRIDE) - #if (LZO_LIBC_NAKED) - # define LZO_INFO_LIBC "naked" - #elif (LZO_LIBC_FREESTANDING) -@@ -1329,6 +2380,9 @@ extern "C" { - # define LZO_INFO_LIBC "isoc90" - #elif (LZO_LIBC_ISOC99) - # define LZO_INFO_LIBC "isoc99" -+#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) -+# define LZO_LIBC_ISOC90 1 -+# define LZO_INFO_LIBC "isoc90" - #elif defined(__dietlibc__) - # define LZO_LIBC_DIETLIBC 1 - # define LZO_INFO_LIBC "dietlibc" -@@ -1337,13 +2391,13 @@ extern "C" { - # define LZO_INFO_LIBC "newlib" - #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) - # if defined(__UCLIBC_SUBLEVEL__) --# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -+# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) - # else - # define LZO_LIBC_UCLIBC 0x00090bL - # endif --# define LZO_INFO_LIBC "uclibc" -+# define LZO_INFO_LIBC "uc" "libc" - #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) --# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) -+# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) - # define LZO_INFO_LIBC "glibc" - #elif (LZO_CC_MWERKS) && defined(__MSL__) - # define LZO_LIBC_MSL __MSL__ -@@ -1356,423 +2410,159 @@ extern "C" { - # define LZO_INFO_LIBC "default" - #endif - #endif --#if !defined(__lzo_gnuc_extension__) --#if (LZO_CC_GNUC >= 0x020800ul) --# define __lzo_gnuc_extension__ __extension__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_gnuc_extension__ __extension__ --#else --# define __lzo_gnuc_extension__ /*empty*/ --#endif --#endif --#if !defined(__lzo_ua_volatile) --# define __lzo_ua_volatile volatile --#endif --#if !defined(__lzo_alignof) --#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_alignof(e) __alignof(e) --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_alignof(e) __alignof__(e) --#endif --#endif --#if defined(__lzo_alignof) --# define __lzo_HAVE_alignof 1 --#endif --#if !defined(__lzo_constructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_constructor __attribute__((__constructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_constructor __attribute__((__constructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_constructor __attribute__((__constructor__)) --#endif --#endif --#if defined(__lzo_constructor) --# define __lzo_HAVE_constructor 1 --#endif --#if !defined(__lzo_destructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_destructor __attribute__((__destructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_destructor __attribute__((__destructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_destructor __attribute__((__destructor__)) --#endif --#endif --#if defined(__lzo_destructor) --# define __lzo_HAVE_destructor 1 --#endif --#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) --# error "this should not happen" --#endif --#if !defined(__lzo_inline) --#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) --#elif defined(__cplusplus) --# define __lzo_inline inline --#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) --# define __lzo_inline __inline --#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_inline __inline__ --#elif (LZO_CC_DMC) --# define __lzo_inline __inline --#elif (LZO_CC_INTELC) --# define __lzo_inline __inline --#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) --# define __lzo_inline __inline --#elif (LZO_CC_MSC && (_MSC_VER >= 900)) --# define __lzo_inline __inline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_inline __inline__ --#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) --# define __lzo_inline inline --#endif --#endif --#if defined(__lzo_inline) --# define __lzo_HAVE_inline 1 --#else --# define __lzo_inline /*empty*/ --#endif --#if !defined(__lzo_forceinline) --#if (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_forceinline __forceinline --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_forceinline __forceinline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#endif --#endif --#if defined(__lzo_forceinline) --# define __lzo_HAVE_forceinline 1 --#else --# define __lzo_forceinline /*empty*/ --#endif --#if !defined(__lzo_noinline) --#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) --# define __lzo_noinline __attribute__((__noinline__,__used__)) --#elif (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) --# define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) --# if defined(__cplusplus) --# else --# define __lzo_noinline __declspec(noinline) --# endif --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_noinline __attribute__((__noinline__)) --#endif --#endif --#if defined(__lzo_noinline) --# define __lzo_HAVE_noinline 1 --#else --# define __lzo_noinline /*empty*/ --#endif --#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) --# error "this should not happen" --#endif --#if !defined(__lzo_noreturn) --#if (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_noreturn __declspec(noreturn) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_noreturn __declspec(noreturn) --#endif --#endif --#if defined(__lzo_noreturn) --# define __lzo_HAVE_noreturn 1 --#else --# define __lzo_noreturn /*empty*/ --#endif --#if !defined(__lzo_nothrow) --#if (LZO_CC_GNUC >= 0x030300ul) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#endif --#endif --#if defined(__lzo_nothrow) --# define __lzo_HAVE_nothrow 1 --#else --# define __lzo_nothrow /*empty*/ --#endif --#if !defined(__lzo_restrict) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) --# define __lzo_restrict __restrict --#endif --#endif --#if defined(__lzo_restrict) --# define __lzo_HAVE_restrict 1 --#else --# define __lzo_restrict /*empty*/ --#endif --#if !defined(__lzo_likely) && !defined(__lzo_unlikely) --#if (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#endif --#endif --#if defined(__lzo_likely) --# define __lzo_HAVE_likely 1 --#else --# define __lzo_likely(e) (e) --#endif --#if defined(__lzo_unlikely) --# define __lzo_HAVE_unlikely 1 --#else --# define __lzo_unlikely(e) (e) --#endif --#if !defined(LZO_UNUSED) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED(var) ((void) &var) --# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNUSED(var) ((void) var) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_KEILC) --# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} --# elif (LZO_CC_PACIFICC) --# define LZO_UNUSED(var) ((void) sizeof(var)) --# elif (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED(var) ((void) var) --# else --# define LZO_UNUSED(var) ((void) &var) --# endif --#endif --#if !defined(LZO_UNUSED_FUNC) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED_FUNC(func) ((void) func) --# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_MSC) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_KEILC || LZO_CC_PELLESC) --# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} --# else --# define LZO_UNUSED_FUNC(func) ((void) func) --# endif --#endif --#if !defined(LZO_UNUSED_LABEL) --# if (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) --# define LZO_UNUSED_LABEL(l) if (0) goto l --# else --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# endif --#endif --#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) --# if 0 --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var --# elif 0 && (LZO_CC_GNUC) --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var --# else --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init --# endif --#endif --#if !defined(LZO_UNCONST_CAST) --# if 0 && defined(__cplusplus) --# define LZO_UNCONST_CAST(t,e) (const_cast (e)) --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) --# else --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) --# endif --#endif --#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) --# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; --# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; --# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; --# else --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; --# endif --#endif --#if !defined(LZO_COMPILE_TIME_ASSERT) --# if (LZO_CC_AZTECC) --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} --# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# else --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} --# endif --#endif --#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) --# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) --# define __lzo_cdecl __cdecl --# define __lzo_cdecl_atexit /*empty*/ --# define __lzo_cdecl_main __cdecl --# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) --# define __lzo_cdecl_qsort __pascal --# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) --# define __lzo_cdecl_qsort _stdcall --# else --# define __lzo_cdecl_qsort __cdecl --# endif --# elif (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --# else --# define __lzo_cdecl __cdecl --# define __lzo_cdecl_atexit __cdecl --# define __lzo_cdecl_main __cdecl --# define __lzo_cdecl_qsort __cdecl --# endif --# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) --# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) --# define __lzo_cdecl_sighandler __pascal --# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) --# define __lzo_cdecl_sighandler _stdcall --# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) --# define __lzo_cdecl_sighandler __clrcall --# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) --# if defined(_DLL) --# define __lzo_cdecl_sighandler _far _cdecl _loadds --# elif defined(_MT) --# define __lzo_cdecl_sighandler _far _cdecl --# else --# define __lzo_cdecl_sighandler _cdecl --# endif --# else --# define __lzo_cdecl_sighandler __cdecl --# endif --#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) --# define __lzo_cdecl cdecl --#endif --#if !defined(__lzo_cdecl) --# define __lzo_cdecl /*empty*/ --#endif --#if !defined(__lzo_cdecl_atexit) --# define __lzo_cdecl_atexit /*empty*/ --#endif --#if !defined(__lzo_cdecl_main) --# define __lzo_cdecl_main /*empty*/ --#endif --#if !defined(__lzo_cdecl_qsort) --# define __lzo_cdecl_qsort /*empty*/ --#endif --#if !defined(__lzo_cdecl_sighandler) --# define __lzo_cdecl_sighandler /*empty*/ --#endif --#if !defined(__lzo_cdecl_va) --# define __lzo_cdecl_va __lzo_cdecl --#endif --#if !(LZO_CFG_NO_WINDOWS_H) --#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) --# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) --# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) --# else --# define LZO_HAVE_WINDOWS_H 1 --# endif -+#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+# define LZO_ASM_SYNTAX_MSC 1 -+#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -+#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_CC_GNUC) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#endif -+#if (LZO_ASM_SYNTAX_GNUC) -+#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -+# define __LZO_ASM_CLOBBER "ax" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) -+# define __LZO_ASM_CLOBBER "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#else -+# define __LZO_ASM_CLOBBER "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC : "cc" -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ - #endif - #endif - #if (LZO_ARCH_ALPHA) --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_AMD64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# define LZO_OPT_UNALIGNED64 1 --#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_ARM) --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# if defined(__ARM_FEATURE_UNALIGNED) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_CRIS) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_I386) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_IA64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_PREFER_POSTINC 1 - #elif (LZO_ARCH_M68K) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if defined(__mc68020__) && !defined(__mcoldfire__) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - # endif - #elif (LZO_ARCH_MIPS) --# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_POWERPC) --# define LZO_OPT_PREFER_PREINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_PREINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if (LZO_ABI_BIG_ENDIAN) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif -+# endif - # endif - #elif (LZO_ARCH_S390) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# if (LZO_SIZEOF_SIZE_T == 8) --# define LZO_OPT_UNALIGNED64 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - # endif - #elif (LZO_ARCH_SH) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - #endif - #ifndef LZO_CFG_NO_INLINE_ASM --#if (LZO_CC_LLVM) -+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) - # define LZO_CFG_NO_INLINE_ASM 1 -+#elif (LZO_CC_LLVM) -+# define LZO_CFG_NO_INLINE_ASM 1 -+#endif - #endif -+#if (LZO_CFG_NO_INLINE_ASM) -+# undef LZO_ASM_SYNTAX_MSC -+# undef LZO_ASM_SYNTAX_GNUC -+# undef __LZO_ASM_CLOBBER -+# undef __LZO_ASM_CLOBBER_LIST_CC -+# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY -+# undef __LZO_ASM_CLOBBER_LIST_EMPTY - #endif - #ifndef LZO_CFG_NO_UNALIGNED - #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) -@@ -1784,25 +2574,6 @@ extern "C" { - # undef LZO_OPT_UNALIGNED32 - # undef LZO_OPT_UNALIGNED64 - #endif --#if (LZO_CFG_NO_INLINE_ASM) --#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --# define LZO_ASM_SYNTAX_MSC 1 --#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) --#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#endif --#if (LZO_ASM_SYNTAX_GNUC) --#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) --# define __LZO_ASM_CLOBBER "ax" --#elif (LZO_CC_INTELC) --# define __LZO_ASM_CLOBBER "memory" --#else --# define __LZO_ASM_CLOBBER "cc", "memory" --#endif --#endif - #if defined(__LZO_INFOSTR_MM) - #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) - # define __LZO_INFOSTR_MM "" -@@ -1846,7 +2617,382 @@ extern "C" { - #define LZO_INFO_STRING \ - LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ - " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER -+#if !(LZO_CFG_SKIP_LZO_TYPES) -+#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if !defined(lzo_llong_t) -+#if (LZO_SIZEOF_LONG_LONG+0 > 0) -+__lzo_gnuc_extension__ typedef long long lzo_llong_t__; -+__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; -+# define lzo_llong_t lzo_llong_t__ -+# define lzo_ullong_t lzo_ullong_t__ -+#endif -+#endif -+#if !defined(lzo_int16e_t) -+#if (LZO_SIZEOF_LONG == 2) -+# define lzo_int16e_t long -+# define lzo_uint16e_t unsigned long -+#elif (LZO_SIZEOF_INT == 2) -+# define lzo_int16e_t int -+# define lzo_uint16e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 2) -+# define lzo_int16e_t short int -+# define lzo_uint16e_t unsigned short int -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) -+ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); -+ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); -+# define lzo_int16e_t lzo_int16e_hi_t__ -+# define lzo_uint16e_t lzo_uint16e_hi_t__ -+#elif (LZO_SIZEOF___INT16 == 2) -+# define lzo_int16e_t __int16 -+# define lzo_uint16e_t unsigned __int16 -+#else -+#endif -+#endif -+#if defined(lzo_int16e_t) -+# define LZO_SIZEOF_LZO_INT16E_T 2 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) -+#endif -+#if !defined(lzo_int32e_t) -+#if (LZO_SIZEOF_LONG == 4) -+# define lzo_int32e_t long int -+# define lzo_uint32e_t unsigned long int -+#elif (LZO_SIZEOF_INT == 4) -+# define lzo_int32e_t int -+# define lzo_uint32e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 4) -+# define lzo_int32e_t short int -+# define lzo_uint32e_t unsigned short int -+#elif (LZO_SIZEOF_LONG_LONG == 4) -+# define lzo_int32e_t lzo_llong_t -+# define lzo_uint32e_t lzo_ullong_t -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+#elif (LZO_SIZEOF___INT32 == 4) -+# define lzo_int32e_t __int32 -+# define lzo_uint32e_t unsigned __int32 -+#else -+#endif -+#endif -+#if defined(lzo_int32e_t) -+# define LZO_SIZEOF_LZO_INT32E_T 4 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) -+#endif -+#if !defined(lzo_int64e_t) -+#if (LZO_SIZEOF___INT64 == 8) -+# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define LZO_CFG_TYPE_PREFER___INT64 1 -+# endif -+#endif -+#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int64e_t int -+# define lzo_uint64e_t unsigned int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG == 8) -+# define lzo_int64e_t long int -+# define lzo_uint64e_t unsigned long int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define lzo_int64e_t lzo_llong_t -+# define lzo_uint64e_t lzo_ullong_t -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0ll) -+# define LZO_UINT64_C(c) ((c) + 0ull) -+# elif 0 -+# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) -+# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) -+# else -+# define LZO_INT64_C(c) (c##LL) -+# define LZO_UINT64_C(c) (c##ULL) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG -+#elif (LZO_SIZEOF___INT64 == 8) -+# define lzo_int64e_t __int64 -+# define lzo_uint64e_t unsigned __int64 -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0i64) -+# define LZO_UINT64_C(c) ((c) + 0ui64) -+# else -+# define LZO_INT64_C(c) (c##i64) -+# define LZO_UINT64_C(c) (c##ui64) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 -+#else -+#endif -+#endif -+#if defined(lzo_int64e_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) -+#endif -+#if !defined(lzo_int32l_t) -+#if defined(lzo_int32e_t) -+# define lzo_int32l_t lzo_int32e_t -+# define lzo_uint32l_t lzo_uint32e_t -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T -+#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int32l_t int -+# define lzo_uint32l_t unsigned int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= 4) -+# define lzo_int32l_t long int -+# define lzo_uint32l_t unsigned long int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG -+#else -+# error "lzo_int32l_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) -+#endif -+#if !defined(lzo_int64l_t) -+#if defined(lzo_int64e_t) -+# define lzo_int64l_t lzo_int64e_t -+# define lzo_uint64l_t lzo_uint64e_t -+# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T -+#else -+#endif -+#endif -+#if defined(lzo_int64l_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) -+#endif -+#if !defined(lzo_int32f_t) -+#if (LZO_SIZEOF_SIZE_T >= 8) -+# define lzo_int32f_t lzo_int64l_t -+# define lzo_uint32f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# define lzo_int32f_t lzo_int32l_t -+# define lzo_uint32f_t lzo_uint32l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) -+#endif -+#if !defined(lzo_int64f_t) -+#if defined(lzo_int64l_t) -+# define lzo_int64f_t lzo_int64l_t -+# define lzo_uint64f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+#endif -+#endif -+#if defined(lzo_int64f_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) -+#endif -+#if !defined(lzo_intptr_t) -+#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) -+# define __LZO_INTPTR_T_IS_POINTER 1 -+ typedef char* lzo_intptr_t; -+ typedef char* lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) -+ typedef __w64 int lzo_intptr_t; -+ typedef __w64 unsigned int lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t short -+# define lzo_uintptr_t unsigned short -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT -+#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_intptr_t int -+# define lzo_uintptr_t unsigned int -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t long -+# define lzo_uintptr_t unsigned long -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t lzo_int64l_t -+# define lzo_uintptr_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# error "lzo_intptr_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) -+#endif -+#if !defined(lzo_word_t) -+#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) -+#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) -+# define lzo_word_t lzo_uintptr_t -+# define lzo_sword_t lzo_intptr_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) -+# define lzo_word_t unsigned long -+# define lzo_sword_t long -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG -+#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) -+# define lzo_word_t unsigned int -+# define lzo_sword_t int -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT -+#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) -+# define lzo_word_t unsigned short -+# define lzo_sword_t short -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT -+#elif (LZO_WORDSIZE == 1) -+# define lzo_word_t unsigned char -+# define lzo_sword_t signed char -+# define LZO_SIZEOF_LZO_WORD_T 1 -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) -+# define lzo_word_t lzo_uint64l_t -+# define lzo_sword_t lzo_int64l_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T -+#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) -+#if 0 -+ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); -+ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); -+# define lzo_word_t lzo_word_t -+# define lzo_sword_t lzo_sword_t -+# define LZO_SIZEOF_LZO_WORD_T 16 -+#endif -+#else -+# error "lzo_word_t" -+#endif -+#endif -+#endif -+#if 1 && defined(lzo_word_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) -+#endif -+#if 1 -+#define lzo_int8_t signed char -+#define lzo_uint8_t unsigned char -+#define LZO_SIZEOF_LZO_INT8_T 1 -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) -+#endif -+#if defined(lzo_int16e_t) -+#define lzo_int16_t lzo_int16e_t -+#define lzo_uint16_t lzo_uint16e_t -+#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) -+#endif -+#if defined(lzo_int32e_t) -+#define lzo_int32_t lzo_int32e_t -+#define lzo_uint32_t lzo_uint32e_t -+#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) -+#endif -+#if defined(lzo_int64e_t) -+#define lzo_int64_t lzo_int64e_t -+#define lzo_uint64_t lzo_uint64e_t -+#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) -+#endif -+#if 1 -+#define lzo_int_least32_t lzo_int32l_t -+#define lzo_uint_least32_t lzo_uint32l_t -+#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) -+#endif -+#if defined(lzo_int64l_t) -+#define lzo_int_least64_t lzo_int64l_t -+#define lzo_uint_least64_t lzo_uint64l_t -+#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) -+#endif -+#if 1 -+#define lzo_int_fast32_t lzo_int32f_t -+#define lzo_uint_fast32_t lzo_uint32f_t -+#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) -+#endif -+#if defined(lzo_int64f_t) -+#define lzo_int_fast64_t lzo_int64f_t -+#define lzo_uint_fast64_t lzo_uint64f_t -+#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) -+#endif -+#if !defined(LZO_INT16_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) ((c) + 0) -+# define LZO_UINT16_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) ((c) + 0L) -+# define LZO_UINT16_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) (c) -+# define LZO_UINT16_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) (c##L) -+# define LZO_UINT16_C(c) (c##UL) -+# else -+# error "LZO_INT16_C" -+# endif -+#endif -+#if !defined(LZO_INT32_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) ((c) + 0) -+# define LZO_UINT32_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) ((c) + 0L) -+# define LZO_UINT32_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) (c) -+# define LZO_UINT32_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) (c##L) -+# define LZO_UINT32_C(c) (c##UL) -+# elif (LZO_SIZEOF_LONG_LONG >= 4) -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+# else -+# error "LZO_INT32_C" -+# endif -+#endif -+#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) ((c) + 0) -+# define LZO_UINT64_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) ((c) + 0L) -+# define LZO_UINT64_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) (c) -+# define LZO_UINT64_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) (c##L) -+# define LZO_UINT64_C(c) (c##UL) -+# else -+# error "LZO_INT64_C" -+# endif -+#endif -+#endif - - #endif /* already included */ - --/* vim:set ts=4 et: */ -+/* vim:set ts=4 sw=4 et: */ -diff --git a/grub-core/lib/minilzo/minilzo.h b/grub-core/lib/minilzo/minilzo.h -index 74fefa9fe20..79374546748 100644 ---- a/grub-core/lib/minilzo/minilzo.h -+++ b/grub-core/lib/minilzo/minilzo.h -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -50,7 +35,7 @@ - #ifndef __MINILZO_H - #define __MINILZO_H 1 - --#define MINILZO_VERSION 0x2050 -+#define MINILZO_VERSION 0x2080 - - #ifdef __LZOCONF_H - # error "you cannot use both LZO and miniLZO" -@@ -78,7 +63,7 @@ extern "C" { - */ - - #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS --#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -+#define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) - #define LZO1X_MEM_DECOMPRESS (0) - - diff --git a/0018-Make-efi-machines-load-an-env-block-from-a-variable.patch b/0014-Make-efi-machines-load-an-env-block-from-a-variable.patch similarity index 74% rename from 0018-Make-efi-machines-load-an-env-block-from-a-variable.patch rename to 0014-Make-efi-machines-load-an-env-block-from-a-variable.patch index 9665d7b..d061461 100644 --- a/0018-Make-efi-machines-load-an-env-block-from-a-variable.patch +++ b/0014-Make-efi-machines-load-an-env-block-from-a-variable.patch @@ -6,30 +6,38 @@ Subject: [PATCH] Make efi machines load an env block from a variable Signed-off-by: Peter Jones --- grub-core/Makefile.core.def | 1 + - grub-core/kern/efi/init.c | 34 +++++++++++++++++++++++++++++++++- - 2 files changed, 34 insertions(+), 1 deletion(-) + grub-core/kern/efi/init.c | 36 +++++++++++++++++++++++++++++++++++- + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index eb1088fd654..41b5e16a3ce 100644 +index 45d3edaa4dc..c865a08b027 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -203,6 +203,7 @@ kernel = { - efi = term/efi/console.c; - efi = kern/acpi.c; +@@ -207,6 +207,7 @@ kernel = { efi = kern/efi/acpi.c; + efi = kern/efi/sb.c; + efi = kern/lockdown.c; + efi = lib/envblk.c; i386_coreboot = kern/i386/pc/acpi.c; i386_multiboot = kern/i386/pc/acpi.c; i386_coreboot = kern/acpi.c; diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index 3dfdf2d22b0..71d2279a0c1 100644 +index 7facacf09c7..6d39bd3ad29 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c -@@ -25,9 +25,40 @@ +@@ -27,8 +27,11 @@ #include #include #include ++ + #include + +#include ++ + #ifdef GRUB_STACK_PROTECTOR + + static grub_efi_guid_t rng_protocol_guid = GRUB_EFI_RNG_PROTOCOL_GUID; +@@ -82,6 +85,36 @@ stack_protector_init (void) grub_addr_t grub_modbase; @@ -54,8 +62,8 @@ index 3dfdf2d22b0..71d2279a0c1 100644 + struct grub_envblk envblk_s = { NULL, 0 }; + grub_envblk_t envblk = &envblk_s; + -+ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid, -+ &envblk_s.size); ++ grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid, &envblk_s.size, ++ (void **) &envblk_s.buf); + if (!envblk_s.buf || envblk_s.size < 1) + return; + @@ -66,7 +74,7 @@ index 3dfdf2d22b0..71d2279a0c1 100644 void grub_efi_init (void) { -@@ -42,10 +73,11 @@ grub_efi_init (void) +@@ -108,10 +141,11 @@ grub_efi_init (void) efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer, 0, 0, 0, NULL); diff --git a/0015-Add-GRUB_DISABLE_UUID.patch b/0015-Add-GRUB_DISABLE_UUID.patch deleted file mode 100644 index 7051dd7..0000000 --- a/0015-Add-GRUB_DISABLE_UUID.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 4 Sep 2014 16:49:25 -0400 -Subject: [PATCH] Add GRUB_DISABLE_UUID. - -This will cause "search --fs-uuid --set=root ..." not to be generated by -grub2-mkconfig, and instead simply attempt to use the grub device name -as it understands it. - -Signed-off-by: Peter Jones ---- - docs/grub.texi | 7 +++++++ - util/grub-mkconfig.in | 22 +++++++++++++++++++--- - util/grub-mkconfig_lib.in | 4 ++-- - 3 files changed, 28 insertions(+), 5 deletions(-) - -diff --git a/docs/grub.texi b/docs/grub.texi -index 87795075a87..6f524305085 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -1441,6 +1441,13 @@ enable the use of partition UUIDs, set this option to @samp{false}. - If this option is set to @samp{true}, disable the generation of recovery - mode menu entries. - -+@item GRUB_DISABLE_UUID -+Normally, @command{grub-mkconfig} will generate menu entries that use -+universally-unique identifiers (UUIDs) to identify various filesystems to -+search for files. This is usually more reliable, but in some cases it may -+not be appropriate. To disable this use of UUIDs, set this option to -+@samp{true}. -+ - @item GRUB_VIDEO_BACKEND - If graphical video support is required, either because the @samp{gfxterm} - graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set, -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 523d4e029bb..9ecbcfb5b43 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -133,12 +133,12 @@ fi - - # Device containing our userland. Typically used for root= parameter. - GRUB_DEVICE="`${grub_probe} --target=device /`" --GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true --GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true -+GRUB_DEVICE_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true -+GRUB_DEVICE_PARTUUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true - - # Device containing our /boot partition. Usually the same as GRUB_DEVICE. - GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" --GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true -+GRUB_DEVICE_BOOT_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true - - # Filesystem for the device containing our userland. Used for stuff like - # choosing Hurd filesystem module. -@@ -158,6 +158,21 @@ if test -f ${sysconfdir}/default/grub ; then - . ${sysconfdir}/default/grub - fi - -+if [ "x$GRUB_DISABLE_UUID" != "xtrue" ]; then -+ if [ -z "$GRUB_DEVICE_UUID" ]; then -+ GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED" -+ fi -+ if [ -z "$GRUB_DEVICE_BOOT_UUID" ]; then -+ GRUB_DEVICE_BOOT_UUID="$GRUB_DEVICE_BOOT_UUID_GENERATED" -+ fi -+ if [ -z "$GRUB_DEVICE_UUID" ]; then -+ GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED" -+ fi -+ if [ -z "$GRUB_DEVICE_PART_UUID" ]; then -+ GRUB_DEVICE_PART_UUID="$GRUB_DEVICE_PART_UUID_GENERATED" -+ fi -+fi -+ - # XXX: should this be deprecated at some point? - if [ "x${GRUB_TERMINAL}" != "x" ] ; then - GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}" -@@ -227,6 +242,7 @@ export GRUB_DEFAULT \ - GRUB_DISABLE_LINUX_UUID \ - GRUB_DISABLE_LINUX_PARTUUID \ - GRUB_DISABLE_RECOVERY \ -+ GRUB_DISABLE_UUID \ - GRUB_VIDEO_BACKEND \ - GRUB_GFXMODE \ - GRUB_BACKGROUND \ -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 0f801cab3e4..1001a12232b 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -156,7 +156,7 @@ prepare_grub_to_access_device () - if [ "x$fs_hint" != x ]; then - echo "set root='$fs_hint'" - fi -- if fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then -+ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then - hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= - echo "if [ x\$feature_platform_search_hint = xy ]; then" - echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" -@@ -173,7 +173,7 @@ grub_get_device_id () - IFS=' - ' - device="$1" -- if fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then -+ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then - echo "$fs_uuid"; - else - echo $device |sed 's, ,_,g' diff --git a/0022-Migrate-PPC-from-Yaboot-to-Grub2.patch b/0015-Migrate-PPC-from-Yaboot-to-Grub2.patch similarity index 98% rename from 0022-Migrate-PPC-from-Yaboot-to-Grub2.patch rename to 0015-Migrate-PPC-from-Yaboot-to-Grub2.patch index 3fbb18a..ee8c7ab 100644 --- a/0022-Migrate-PPC-from-Yaboot-to-Grub2.patch +++ b/0015-Migrate-PPC-from-Yaboot-to-Grub2.patch @@ -12,10 +12,10 @@ maximum screen size so that text is not overwritten. create mode 100644 util/grub.d/20_ppc_terminfo.in diff --git a/Makefile.util.def b/Makefile.util.def -index 969d32f0097..8717774d510 100644 +index f8b356cc1fa..2c9b283a230 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -496,6 +496,13 @@ script = { +@@ -508,6 +508,13 @@ script = { condition = COND_HOST_LINUX; }; diff --git a/0023-Add-fw_path-variable-revised.patch b/0016-Add-fw_path-variable-revised.patch similarity index 91% rename from 0023-Add-fw_path-variable-revised.patch rename to 0016-Add-fw_path-variable-revised.patch index 36c3b1f..df9ef83 100644 --- a/0023-Add-fw_path-variable-revised.patch +++ b/0016-Add-fw_path-variable-revised.patch @@ -14,10 +14,10 @@ https://bugzilla.redhat.com/show_bug.cgi?id=857936 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 9cad0c4485c..8ab7794c47b 100644 +index 73967e2f5b0..d1de9fa6873 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c -@@ -127,16 +127,15 @@ grub_set_prefix_and_root (void) +@@ -128,16 +128,15 @@ grub_set_prefix_and_root (void) grub_machine_get_bootlocation (&fwdevice, &fwpath); @@ -41,10 +41,10 @@ index 9cad0c4485c..8ab7794c47b 100644 } diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 222e239c1be..394bfbea868 100644 +index 70614de1565..62571e6dfcc 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -338,7 +338,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -339,7 +339,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), /* Guess the config filename. It is necessary to make CONFIG static, so that it won't get broken by longjmp. */ char *config; diff --git a/0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch b/0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch deleted file mode 100644 index 942116a..0000000 --- a/0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 22 Jul 2015 11:21:01 -0400 -Subject: [PATCH] Mark po/exclude.pot as binary so git won't try to diff - nonprintables. - -Signed-off-by: Peter Jones ---- - .gitattributes | 1 + - 1 file changed, 1 insertion(+) - create mode 100644 .gitattributes - -diff --git a/.gitattributes b/.gitattributes -new file mode 100644 -index 00000000000..33ffaa40460 ---- /dev/null -+++ b/.gitattributes -@@ -0,0 +1 @@ -+po/exclude.pot binary diff --git a/0024-Pass-x-hex-hex-straight-through-unmolested.patch b/0017-Pass-x-hex-hex-straight-through-unmolested.patch similarity index 86% rename from 0024-Pass-x-hex-hex-straight-through-unmolested.patch rename to 0017-Pass-x-hex-hex-straight-through-unmolested.patch index 4fd7811..b81abb5 100644 --- a/0024-Pass-x-hex-hex-straight-through-unmolested.patch +++ b/0017-Pass-x-hex-hex-straight-through-unmolested.patch @@ -3,17 +3,20 @@ From: Peter Jones Date: Mon, 1 Oct 2012 13:24:37 -0400 Subject: [PATCH] Pass "\x[[:hex:]][[:hex:]]" straight through unmolested. +Don't munge raw spaces when we're doing our cmdline escaping (#923374) + +Signed-off-by: Peter Jones --- grub-core/commands/wildcard.c | 16 +++++++++++++++- - grub-core/lib/cmdline.c | 34 ++++++++++++++++++++++++++++++++-- + grub-core/lib/cmdline.c | 25 +++++++++++++++++++++++-- grub-core/script/execute.c | 43 +++++++++++++++++++++++++++++++++++++------ - 3 files changed, 84 insertions(+), 9 deletions(-) + 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c -index 4a106ca040b..560d437cdc6 100644 +index cc3290311f0..8f67a4be7f0 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c -@@ -462,6 +462,12 @@ check_file (const char *dir, const char *basename) +@@ -488,6 +488,12 @@ check_file (const char *dir, const char *basename) return ctx.found; } @@ -26,7 +29,7 @@ index 4a106ca040b..560d437cdc6 100644 static void unescape (char *out, const char *in, const char *end) { -@@ -470,7 +476,15 @@ unescape (char *out, const char *in, const char *end) +@@ -496,7 +502,15 @@ unescape (char *out, const char *in, const char *end) for (optr = out, iptr = in; iptr < end;) { @@ -44,7 +47,7 @@ index 4a106ca040b..560d437cdc6 100644 *optr++ = iptr[1]; iptr += 2; diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index ed0b149dca5..e0fb0a9e48a 100644 +index ed0b149dca5..8e2294d8ff6 100644 --- a/grub-core/lib/cmdline.c +++ b/grub-core/lib/cmdline.c @@ -20,6 +20,12 @@ @@ -75,21 +78,12 @@ index ed0b149dca5..e0fb0a9e48a 100644 size++; else if (*c == ' ') space = 1; -@@ -86,7 +98,25 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf, +@@ -86,7 +98,16 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf, while (*c) { - if (*c == '\\' || *c == '\'' || *c == '"') -+ if (*c == ' ') -+ { -+ *buf++ = '\\'; -+ *buf++ = 'x'; -+ *buf++ = '2'; -+ *buf++ = '0'; -+ c++; -+ continue; -+ } -+ else if (*c == '\\' && *(c+1) == 'x' && ++ if (*c == '\\' && *(c+1) == 'x' && + is_hex(*(c+2)) && is_hex(*(c+3))) + { + *buf++ = *c++; @@ -103,7 +97,7 @@ index ed0b149dca5..e0fb0a9e48a 100644 *buf++ = *c; diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index 0d05d6b0709..ba38b5e8aef 100644 +index ad80399246a..0c6dd9c5201 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -56,6 +56,12 @@ static struct grub_script_scope *scope = 0; diff --git a/0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch b/0018-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch similarity index 91% rename from 0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch rename to 0018-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch index ada4564..8c1a167 100644 --- a/0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch +++ b/0018-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch @@ -14,7 +14,7 @@ Signed-off-by: Javier Martinez Canillas Signed-off-by: Will Thompson --- grub-core/Makefile.core.def | 11 + - grub-core/commands/blscfg.c | 1096 ++++++++++++++++++++++++++++++++++++++++ + grub-core/commands/blscfg.c | 1171 ++++++++++++++++++++++++++++++++++++++++ grub-core/commands/legacycfg.c | 5 +- grub-core/commands/loadenv.c | 77 +-- grub-core/commands/menuentry.c | 20 +- @@ -23,15 +23,15 @@ Signed-off-by: Will Thompson include/grub/compiler.h | 2 + include/grub/menu.h | 13 + include/grub/normal.h | 2 +- - 10 files changed, 1243 insertions(+), 82 deletions(-) + 10 files changed, 1318 insertions(+), 82 deletions(-) create mode 100644 grub-core/commands/blscfg.c create mode 100644 grub-core/commands/loadenv.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 41b5e16a3ce..57e253ab1a1 100644 +index c865a08b027..c15e91943b9 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -811,6 +811,16 @@ module = { +@@ -814,6 +814,16 @@ module = { common = commands/blocklist.c; }; @@ -48,7 +48,7 @@ index 41b5e16a3ce..57e253ab1a1 100644 module = { name = boot; common = commands/boot.c; -@@ -988,6 +998,7 @@ module = { +@@ -980,6 +990,7 @@ module = { module = { name = loadenv; common = commands/loadenv.c; @@ -58,10 +58,10 @@ index 41b5e16a3ce..57e253ab1a1 100644 diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c new file mode 100644 -index 00000000000..54458b14518 +index 00000000000..ab35c75443a --- /dev/null +++ b/grub-core/commands/blscfg.c -@@ -0,0 +1,1096 @@ +@@ -0,0 +1,1171 @@ +/*-*- Mode: C; c-basic-offset: 2; indent-tabs-mode: t -*-*/ + +/* bls.c - implementation of the boot loader spec */ @@ -227,8 +227,8 @@ index 00000000000..54458b14518 + + /* loop through each version segment of str1 and str2 and compare them */ + while (*one || *two) { -+ while (*one && !grub_isalnum(*one) && *one != '~') one++; -+ while (*two && !grub_isalnum(*two) && *two != '~') two++; ++ while (*one && !grub_isalnum(*one) && *one != '~' && *one != '+') one++; ++ while (*two && !grub_isalnum(*two) && *two != '~' && *two != '+') two++; + + /* handle the tilde separator, it sorts before everything else */ + if (*one == '~' || *two == '~') { @@ -239,6 +239,21 @@ index 00000000000..54458b14518 + continue; + } + ++ /* ++ * Handle plus separator. Concept is the same as tilde, ++ * except that if one of the strings ends (base version), ++ * the other is considered as higher version. ++ */ ++ if (*one == '+' || *two == '+') { ++ if (!*one) return -1; ++ if (!*two) return 1; ++ if (*one != '+') goto_return (1); ++ if (*two != '+') goto_return (-1); ++ one++; ++ two++; ++ continue; ++ } ++ + /* If we ran to the end of either, we are finished with the loop */ + if (!(*one && *two)) break; + @@ -649,13 +664,19 @@ index 00000000000..54458b14518 + list[nlist] = NULL; + } + ++ if (!nlist) ++ { ++ grub_free (list); ++ return NULL; ++ } ++ + if (num) + *num = nlist; + + return list; +} + -+static char *field_append(bool is_var, char *buffer, char *start, char *end) ++static char *field_append(bool is_var, char *buffer, const char *start, const char *end) +{ + char *temp = grub_strndup(start, end - start + 1); + const char *field = temp; @@ -666,26 +687,25 @@ index 00000000000..54458b14518 + return buffer; + } + -+ if (!buffer) { -+ buffer = grub_strdup(field); -+ if (!buffer) -+ return NULL; -+ } else { -+ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field)); -+ if (!buffer) -+ return NULL; ++ if (!buffer) ++ buffer = grub_zalloc (grub_strlen(field) + 1); ++ else ++ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field) + 1); + -+ grub_stpcpy (buffer + grub_strlen(buffer), field); -+ } ++ if (!buffer) ++ return NULL; ++ ++ grub_stpcpy (buffer + grub_strlen(buffer), field); ++ grub_stpcpy (buffer + grub_strlen(buffer), " "); + + return buffer; +} + -+static char *expand_val(char *value) ++static char *expand_val(const char *value) +{ + char *buffer = NULL; -+ char *start = value; -+ char *end = value; ++ const char *start = value; ++ const char *end = value; + bool is_var = false; + + if (!value) @@ -762,6 +782,8 @@ index 00000000000..54458b14518 + const char *early_initrd = NULL; + char **early_initrds = NULL; + char *initrd_prefix = NULL; ++ char *devicetree = NULL; ++ char *dt = NULL; + char *id = entry->filename; + char *dotconf = id; + char *hotkey = NULL; @@ -773,6 +795,7 @@ index 00000000000..54458b14518 + + char *src = NULL; + int i, index; ++ bool add_dt_prefix = false; + + grub_dprintf("blscfg", "%s got here\n", __func__); + clinux = bls_get_val (entry, "linux", NULL); @@ -800,6 +823,14 @@ index 00000000000..54458b14518 + + initrds = bls_make_list (entry, "initrd", NULL); + ++ devicetree = expand_val (bls_get_val (entry, "devicetree", NULL)); ++ ++ if (!devicetree) ++ { ++ devicetree = expand_val (grub_env_get("devicetree")); ++ add_dt_prefix = true; ++ } ++ + hotkey = bls_get_val (entry, "grub_hotkey", NULL); + users = expand_val (bls_get_val (entry, "grub_users", NULL)); + classes = bls_make_list (entry, "grub_class", NULL); @@ -865,7 +896,6 @@ index 00000000000..54458b14518 + goto finish; + } + -+ + tmp = grub_stpcpy(initrd, "initrd"); + for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) + { @@ -885,21 +915,68 @@ index 00000000000..54458b14518 + tmp = grub_stpcpy (tmp, "\n"); + } + -+ src = grub_xasprintf ("load_video\n" ++ if (devicetree) ++ { ++ char *prefix = NULL; ++ int dt_size; ++ ++ if (add_dt_prefix) ++ { ++ prefix = grub_strrchr (clinux, '/'); ++ prefix = grub_strndup(clinux, prefix - clinux + 1); ++ if (!prefix) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ } ++ ++ dt_size = sizeof("devicetree " GRUB_BOOT_DEVICE) + grub_strlen(devicetree) + 1; ++ ++ if (add_dt_prefix) ++ { ++ dt_size += grub_strlen(prefix); ++ } ++ ++ dt = grub_malloc (dt_size); ++ if (!dt) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ char *tmp = dt; ++ tmp = grub_stpcpy (dt, "devicetree"); ++ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); ++ if (add_dt_prefix) ++ tmp = grub_stpcpy (tmp, prefix); ++ tmp = grub_stpcpy (tmp, devicetree); ++ tmp = grub_stpcpy (tmp, "\n"); ++ ++ grub_free(prefix); ++ } ++ ++ grub_dprintf ("blscfg2", "devicetree %s for id:\"%s\"\n", dt, id); ++ ++ const char *sdval = grub_env_get("save_default"); ++ bool savedefault = ((NULL != sdval) && (grub_strcmp(sdval, "true") == 0)); ++ src = grub_xasprintf ("%sload_video\n" + "set gfxpayload=keep\n" + "insmod gzio\n" + "linux %s%s%s%s\n" -+ "%s", ++ "%s%s", ++ savedefault ? "savedefault\n" : "", + GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", -+ initrd ? initrd : ""); ++ initrd ? initrd : "", dt ? dt : ""); + + grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index, entry); + grub_dprintf ("blscfg", "Added entry %d id:\"%s\"\n", index, id); + +finish: ++ grub_free (dt); + grub_free (initrd); + grub_free (initrd_prefix); + grub_free (early_initrds); ++ grub_free (devicetree); + grub_free (initrds); + grub_free (options); + grub_free (classes); @@ -1009,14 +1086,12 @@ index 00000000000..54458b14518 + if (!devid) { +#ifdef GRUB_MACHINE_EMU + devid = "host"; -+#elif defined(GRUB_MACHINE_EFI) -+ devid = grub_env_get ("root"); +#else -+ devid = grub_env_get ("boot"); ++ devid = grub_env_get ("root"); +#endif + if (!devid) + return grub_error (GRUB_ERR_FILE_NOT_FOUND, -+ N_("variable `%s' isn't set"), "boot"); ++ N_("variable `%s' isn't set"), "root"); + } + + grub_dprintf ("blscfg", "opening %s\n", devid); @@ -1159,10 +1234,10 @@ index 00000000000..54458b14518 + grub_unregister_extcmd (oldcmd); +} diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c -index db7a8f00273..891eac5a33f 100644 +index cc5971f4dbd..782761c31aa 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c -@@ -133,7 +133,7 @@ legacy_file (const char *filename) +@@ -143,7 +143,7 @@ legacy_file (const char *filename) args[0] = oldname; grub_normal_add_menu_entry (1, args, NULL, NULL, "legacy", NULL, NULL, @@ -1171,7 +1246,7 @@ index db7a8f00273..891eac5a33f 100644 grub_free (args); entrysrc[0] = 0; grub_free (oldname); -@@ -186,7 +186,8 @@ legacy_file (const char *filename) +@@ -205,7 +205,8 @@ legacy_file (const char *filename) } args[0] = entryname; grub_normal_add_menu_entry (1, args, NULL, NULL, NULL, @@ -1277,7 +1352,7 @@ index 3fd664aac33..163b9a09042 100644 grub_cmd_load_env (grub_extcmd_context_t ctxt, int argc, char **args) { diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index 2c5363da7f5..9faf2be0f64 100644 +index 720e6d8ea3b..b194123eb67 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -78,7 +78,7 @@ grub_normal_add_menu_entry (int argc, const char **args, @@ -1301,7 +1376,7 @@ index 2c5363da7f5..9faf2be0f64 100644 + grub_dprintf ("menu", "menu_id:\"%s\"\n", menu_id); /* Save argc, args to pass as parameters to block arg later. */ - menu_args = grub_malloc (sizeof (char*) * (argc + 1)); + menu_args = grub_calloc (argc + 1, sizeof (char *)); @@ -170,8 +173,12 @@ grub_normal_add_menu_entry (int argc, const char **args, } @@ -1349,11 +1424,11 @@ index 2c5363da7f5..9faf2be0f64 100644 src[len - 1] = ch; args[argc - 1] = src; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 9ef98481f70..a326b192c89 100644 +index 62571e6dfcc..7ca2e5400b1 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -20,6 +20,7 @@ - #include +@@ -21,6 +21,7 @@ + #include #include #include +#include @@ -1472,11 +1547,11 @@ index 00000000000..952f46121bd + return 0; +} diff --git a/include/grub/compiler.h b/include/grub/compiler.h -index c9e1d7a73dc..9859ff4cc79 100644 +index 8f3be3ae706..ebafec68957 100644 --- a/include/grub/compiler.h +++ b/include/grub/compiler.h -@@ -48,4 +48,6 @@ - # define WARN_UNUSED_RESULT +@@ -56,4 +56,6 @@ + # define CLANG_PREREQ(maj,min) 0 #endif +#define UNUSED __attribute__((__unused__)) diff --git a/0028-Add-devicetree-loading.patch b/0019-Add-devicetree-loading.patch similarity index 94% rename from 0028-Add-devicetree-loading.patch rename to 0019-Add-devicetree-loading.patch index 2558faa..e55047e 100644 --- a/0028-Add-devicetree-loading.patch +++ b/0019-Add-devicetree-loading.patch @@ -20,10 +20,10 @@ Signed-off-by: David A. Marlin 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 9ecbcfb5b43..c645351dd2a 100644 +index f8cbb8d7a2b..91d761bae80 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -254,7 +254,8 @@ export GRUB_DEFAULT \ +@@ -251,7 +251,8 @@ export GRUB_DEFAULT \ GRUB_ENABLE_CRYPTODISK \ GRUB_BADRAM \ GRUB_OS_PROBER_SKIP_LIST \ @@ -34,7 +34,7 @@ index 9ecbcfb5b43..c645351dd2a 100644 if test "x${grub_cfg}" != "x"; then rm -f "${grub_cfg}.new" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 58defdbd83f..dd3128440c4 100644 +index e8b01c0d0c7..dc75a1c30bf 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -153,6 +153,13 @@ EOF diff --git a/0019-DHCP-client-ID-and-UUID-options-added.patch b/0019-DHCP-client-ID-and-UUID-options-added.patch deleted file mode 100644 index 6167b62..0000000 --- a/0019-DHCP-client-ID-and-UUID-options-added.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Mon, 8 Jul 2019 14:10:58 +0200 -Subject: [PATCH] DHCP client ID and UUID options added. - ---- - grub-core/net/bootp.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++----- - include/grub/net.h | 2 ++ - 2 files changed, 79 insertions(+), 8 deletions(-) - -diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 04cfbb04504..0e6e41a1699 100644 ---- a/grub-core/net/bootp.c -+++ b/grub-core/net/bootp.c -@@ -95,6 +95,49 @@ enum - /* Max timeout when waiting for BOOTP/DHCP reply */ - #define GRUB_DHCP_MAX_PACKET_TIMEOUT 32 - -+static char * -+grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), -+ const char *val __attribute__ ((unused))) -+{ -+ return NULL; -+} -+ -+static void -+set_env_limn_ro (const char *intername, const char *suffix, -+ const char *value, grub_size_t len) -+{ -+ char *varname, *varvalue; -+ char *ptr; -+ varname = grub_xasprintf ("net_%s_%s", intername, suffix); -+ if (!varname) -+ return; -+ for (ptr = varname; *ptr; ptr++) -+ if (*ptr == ':') -+ *ptr = '_'; -+ varvalue = grub_malloc (len + 1); -+ if (!varvalue) -+ { -+ grub_free (varname); -+ return; -+ } -+ -+ grub_memcpy (varvalue, value, len); -+ varvalue[len] = 0; -+ grub_env_set (varname, varvalue); -+ grub_register_variable_hook (varname, 0, grub_env_write_readonly); -+ grub_env_export (varname); -+ grub_free (varname); -+ grub_free (varvalue); -+} -+ -+static char -+hexdigit (grub_uint8_t val) -+{ -+ if (val < 10) -+ return val + '0'; -+ return val + 'a' - 10; -+} -+ - static const void * - find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, - grub_uint8_t opt_code, grub_uint8_t *opt_len) -@@ -152,6 +195,9 @@ again: - if (i + taglength >= size) - return NULL; - -+ grub_dprintf("net", "DHCP option %u (0x%02x) found with length %u.\n", -+ tagtype, tagtype, taglength); -+ - /* FIXME RFC 3396 options concatentation */ - if (tagtype == opt_code) - { -@@ -354,6 +400,37 @@ grub_net_configure_by_dhcp_ack (const char *name, - } - grub_net_add_ipv4_local (inter, mask); - -+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_CLIENT_ID, &opt_len); -+ if (opt) -+ { -+ set_env_limn_ro (name, "clientid", (char *) opt, opt_len); -+ } -+ -+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_CLIENT_UUID, &opt_len); -+ if (opt && opt_len == 17) -+ { -+ /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */ -+ -+ opt += 1; -+ opt_len -= 1; -+ -+ char *val = grub_malloc (2 * opt_len + 4 + 1); -+ int i = 0; -+ int j = 0; -+ for (i = 0; i < opt_len; i++) -+ { -+ val[2 * i + j] = hexdigit (opt[i] >> 4); -+ val[2 * i + 1 + j] = hexdigit (opt[i] & 0xf); -+ -+ if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) -+ { -+ j++; -+ val[2 * i + 1+ j] = '-'; -+ } -+ } -+ set_env_limn_ro (name, "clientuuid", (char *) val, 2 * opt_len + 4); -+ } -+ - /* We do not implement dead gateway detection and the first entry SHOULD - be preferred one */ - opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_ROUTER, &opt_len); -@@ -631,14 +708,6 @@ grub_net_process_dhcp (struct grub_net_buff *nb, - } - } - --static char --hexdigit (grub_uint8_t val) --{ -- if (val < 10) -- return val + '0'; -- return val + 'a' - 10; --} -- - static grub_err_t - grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), - int argc, char **args) -diff --git a/include/grub/net.h b/include/grub/net.h -index 4a9069a1474..556c54e579f 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -462,6 +462,8 @@ enum - GRUB_NET_BOOTP_DOMAIN = 0x0f, - GRUB_NET_BOOTP_ROOT_PATH = 0x11, - GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, -+ GRUB_NET_BOOTP_CLIENT_ID = 0x3d, -+ GRUB_NET_BOOTP_CLIENT_UUID = 0x61, - GRUB_NET_DHCP_REQUESTED_IP_ADDRESS = 50, - GRUB_NET_DHCP_OVERLOAD = 52, - GRUB_NET_DHCP_MESSAGE_TYPE = 53, diff --git a/0029-Don-t-write-messages-to-the-screen.patch b/0020-Don-t-write-messages-to-the-screen.patch similarity index 89% rename from 0029-Don-t-write-messages-to-the-screen.patch rename to 0020-Don-t-write-messages-to-the-screen.patch index 5677434..0decd84 100644 --- a/0029-Don-t-write-messages-to-the-screen.patch +++ b/0020-Don-t-write-messages-to-the-screen.patch @@ -8,11 +8,10 @@ happens so quickly it looks like something is wrong and isn't very appealing. --- grub-core/gettext/gettext.c | 25 +++++-------------------- - grub-core/kern/main.c | 5 ----- grub-core/boot/i386/pc/boot.S | 3 --- grub-core/boot/i386/pc/diskboot.S | 5 ----- util/grub.d/10_linux.in | 7 ------- - 5 files changed, 5 insertions(+), 40 deletions(-) + 4 files changed, 5 insertions(+), 35 deletions(-) diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c index 4d02e62c109..84d520cd494 100644 @@ -96,22 +95,6 @@ index 4d02e62c109..84d520cd494 100644 grub_register_variable_hook ("locale_dir", NULL, read_main); grub_register_variable_hook ("secondary_locale_dir", NULL, read_secondary); -diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 8ab7794c47b..da47b18b50e 100644 ---- a/grub-core/kern/main.c -+++ b/grub-core/kern/main.c -@@ -268,11 +268,6 @@ grub_main (void) - - grub_boot_time ("After machine init."); - -- /* Hello. */ -- grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); -- grub_printf ("Welcome to GRUB!\n\n"); -- grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); -- - grub_load_config (); - - grub_boot_time ("Before loading embedded modules."); diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S index 2bd0b2d2866..ea167fe1206 100644 --- a/grub-core/boot/i386/pc/boot.S @@ -143,7 +126,7 @@ index c1addc0df29..68d31de0c4c 100644 movw $LOCAL(firstlist), %di diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index dd3128440c4..ceb413fc2e3 100644 +index dc75a1c30bf..ad2ac4b078d 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -138,27 +138,20 @@ linux_entry () diff --git a/0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch b/0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch deleted file mode 100644 index 265e777..0000000 --- a/0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Prarit Bhargava -Date: Wed, 12 Mar 2014 10:58:16 -0400 -Subject: [PATCH] Fix bad test on GRUB_DISABLE_SUBMENU. - -The file /etc/grub.d/10_linux does - -if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then - -when it should do - -if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then - -which results in submenus in /boot/grub2/grub.cfg when -GRUB_DISABLE_SUBMENU="yes". - -Resolves: rhbz#1063414 ---- - util/grub.d/10_linux.in | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 4532266be68..58defdbd83f 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -261,7 +261,11 @@ while [ "x$list" != "x" ] ; do - fi - fi - -- if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then -+ if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then -+ GRUB_DISABLE_SUBMENU="true" -+ fi -+ -+ if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then - linux_entry "${OS}" "${version}" simple \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - diff --git a/0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch b/0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch deleted file mode 100644 index 6ddda34..0000000 --- a/0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Wed, 12 Jun 2013 11:51:49 -0400 -Subject: [PATCH] Add support for UEFI operating systems returned by os-prober - -os-prober returns UEFI operating systems in the form: - -path:long-name:name - -where path is the path under the EFI directory on the ESP. This is in -contrast to legacy OSes, where path is the device string. Handle this case. ---- - util/grub.d/30_os-prober.in | 21 ++++++++++++++++++--- - 1 file changed, 18 insertions(+), 3 deletions(-) - -diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 515a68c7aa0..9b8f5968e2d 100644 ---- a/util/grub.d/30_os-prober.in -+++ b/util/grub.d/30_os-prober.in -@@ -328,8 +328,23 @@ EOF - EOF - ;; - *) -- # TRANSLATORS: %s is replaced by OS name. -- gettext_printf "%s is not yet supported by grub-mkconfig.\n" " ${LONGNAME}" >&2 -- ;; -+ case ${DEVICE} in -+ *.efi) -+ cat << EOF -+menuentry '$(echo "${LONGNAME}" | grub_quote)' { -+EOF -+ save_default_entry | grub_add_tab -+ cat << EOF -+ chainloader /EFI/${DEVICE} -+ boot -+} -+EOF -+ ;; -+ *) -+ echo -n " " -+ # TRANSLATORS: %s is replaced by OS name. -+ gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2 -+ ;; -+ esac - esac - done diff --git a/0030-Don-t-print-GNU-GRUB-header.patch b/0021-Don-t-print-GNU-GRUB-header.patch similarity index 96% rename from 0030-Don-t-print-GNU-GRUB-header.patch rename to 0021-Don-t-print-GNU-GRUB-header.patch index ce45d4b..c903fd4 100644 --- a/0030-Don-t-print-GNU-GRUB-header.patch +++ b/0021-Don-t-print-GNU-GRUB-header.patch @@ -9,7 +9,7 @@ No one cares. 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index a326b192c89..09d0dfe76f1 100644 +index 7ca2e5400b1..5d5f7b539f5 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -208,15 +208,16 @@ read_config_file (const char *config) diff --git a/0031-Don-t-add-to-highlighted-row.patch b/0022-Don-t-add-to-highlighted-row.patch similarity index 95% rename from 0031-Don-t-add-to-highlighted-row.patch rename to 0022-Don-t-add-to-highlighted-row.patch index b2d5575..b83f543 100644 --- a/0031-Don-t-add-to-highlighted-row.patch +++ b/0022-Don-t-add-to-highlighted-row.patch @@ -9,7 +9,7 @@ It is already highlighted. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index e22bb91f6e8..a3d1f23f68f 100644 +index 18240e76cea..65deafda531 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -242,7 +242,7 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, diff --git a/0032-Message-string-cleanups.patch b/0023-Message-string-cleanups.patch similarity index 98% rename from 0032-Message-string-cleanups.patch rename to 0023-Message-string-cleanups.patch index 9b6208e..e23ee1a 100644 --- a/0032-Message-string-cleanups.patch +++ b/0023-Message-string-cleanups.patch @@ -9,7 +9,7 @@ Make use of terminology consistent. Remove jargon. 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index a3d1f23f68f..64a83862f66 100644 +index 65deafda531..cc5837ed2b8 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -157,9 +157,8 @@ print_message (int nested, int edit, struct grub_term_output *term, int dry_run) diff --git a/0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch b/0024-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch similarity index 96% rename from 0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch rename to 0024-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch index 504f273..920ef79 100644 --- a/0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch +++ b/0024-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch @@ -8,7 +8,7 @@ Subject: [PATCH] Fix border spacing now that we aren't displaying it 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 64a83862f66..1062d64ee29 100644 +index cc5837ed2b8..b49835a9af7 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -331,12 +331,12 @@ grub_menu_init_page (int nested, int edit, diff --git a/0025-Add-X-option-to-printf-functions.patch b/0025-Add-X-option-to-printf-functions.patch deleted file mode 100644 index 5f2a075..0000000 --- a/0025-Add-X-option-to-printf-functions.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Tue, 27 Nov 2012 16:58:39 -0200 -Subject: [PATCH] Add %X option to printf functions. - ---- - grub-core/kern/misc.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index cd63a8cea73..2656a670e09 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -588,7 +588,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) - static inline char * - grub_lltoa (char *str, int c, unsigned long long n) - { -- unsigned base = (c == 'x') ? 16 : 10; -+ unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10; - char *p; - - if ((long long) n < 0 && c == 'd') -@@ -603,7 +603,7 @@ grub_lltoa (char *str, int c, unsigned long long n) - do - { - unsigned d = (unsigned) (n & 0xf); -- *p++ = (d > 9) ? d + 'a' - 10 : d + '0'; -+ *p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0'; - } - while (n >>= 4); - else -@@ -676,6 +676,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, - { - case 'p': - case 'x': -+ case 'X': - case 'u': - case 'd': - case 'c': -@@ -762,6 +763,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, - switch (c) - { - case 'x': -+ case 'X': - case 'u': - args->ptr[curn].type = UNSIGNED_INT + longfmt; - break; -@@ -900,6 +902,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, - c = 'x'; - /* Fall through. */ - case 'x': -+ case 'X': - case 'u': - case 'd': - { diff --git a/0034-Use-the-correct-indentation-for-the-term-help-text.patch b/0025-Use-the-correct-indentation-for-the-term-help-text.patch similarity index 90% rename from 0034-Use-the-correct-indentation-for-the-term-help-text.patch rename to 0025-Use-the-correct-indentation-for-the-term-help-text.patch index 5a1f0b5..0ce3b04 100644 --- a/0034-Use-the-correct-indentation-for-the-term-help-text.patch +++ b/0025-Use-the-correct-indentation-for-the-term-help-text.patch @@ -9,10 +9,10 @@ That is consistent with the menu help text 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 09d0dfe76f1..7f61c5b618b 100644 +index 5d5f7b539f5..ec1cd257397 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -432,8 +432,8 @@ grub_normal_reader_init (int nested) +@@ -440,8 +440,8 @@ grub_normal_reader_init (int nested) grub_normal_init_page (term, 1); grub_term_setcursor (term, 1); diff --git a/0035-Indent-menu-entries.patch b/0026-Indent-menu-entries.patch similarity index 95% rename from 0035-Indent-menu-entries.patch rename to 0026-Indent-menu-entries.patch index 7a843ec..7e588fd 100644 --- a/0035-Indent-menu-entries.patch +++ b/0026-Indent-menu-entries.patch @@ -8,7 +8,7 @@ Subject: [PATCH] Indent menu entries 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 1062d64ee29..ecc60f99fc3 100644 +index b49835a9af7..6a57376fa80 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -239,7 +239,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, diff --git a/0026-Search-for-specific-config-file-for-netboot.patch b/0026-Search-for-specific-config-file-for-netboot.patch deleted file mode 100644 index f94911c..0000000 --- a/0026-Search-for-specific-config-file-for-netboot.patch +++ /dev/null @@ -1,200 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Tue, 27 Nov 2012 17:22:07 -0200 -Subject: [PATCH] Search for specific config file for netboot - -This patch implements a search for a specific configuration when the config -file is on a remoteserver. It uses the following order: - 1) DHCP client UUID option. - 2) MAC address (in lower case hexadecimal with dash separators); - 3) IP (in upper case hexadecimal) or IPv6; - 4) The original grub.cfg file. - -This procedure is similar to what is used by pxelinux and yaboot: -http://www.syslinux.org/wiki/index.php/PXELINUX#config - -This should close the bugzilla: -https://bugzilla.redhat.com/show_bug.cgi?id=873406 ---- - grub-core/net/net.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++ - grub-core/normal/main.c | 18 ++++++-- - include/grub/net.h | 3 ++ - 3 files changed, 135 insertions(+), 4 deletions(-) - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index d5d726a315e..06454564b8f 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -1735,6 +1735,124 @@ grub_net_restore_hw (void) - return GRUB_ERR_NONE; - } - -+grub_err_t -+grub_net_search_configfile (char *config) -+{ -+ grub_size_t config_len; -+ char *suffix; -+ -+ auto int search_through (grub_size_t num_tries, grub_size_t slice_size); -+ int search_through (grub_size_t num_tries, grub_size_t slice_size) -+ { -+ while (num_tries-- > 0) -+ { -+ grub_dprintf ("net", "probe %s\n", config); -+ -+ grub_file_t file; -+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); -+ -+ if (file) -+ { -+ grub_file_close (file); -+ grub_dprintf ("net", "found!\n"); -+ return 0; -+ } -+ else -+ { -+ if (grub_errno == GRUB_ERR_IO) -+ grub_errno = GRUB_ERR_NONE; -+ } -+ -+ if (grub_strlen (suffix) < slice_size) -+ break; -+ -+ config[grub_strlen (config) - slice_size] = '\0'; -+ } -+ -+ return 1; -+ } -+ -+ config_len = grub_strlen (config); -+ config[config_len] = '-'; -+ suffix = config + config_len + 1; -+ -+ struct grub_net_network_level_interface *inf; -+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf) -+ { -+ /* By the Client UUID. */ -+ -+ char client_uuid_var[sizeof ("net_") + grub_strlen (inf->name) + -+ sizeof ("_clientuuid") + 1]; -+ grub_snprintf (client_uuid_var, sizeof (client_uuid_var), -+ "net_%s_clientuuid", inf->name); -+ -+ const char *client_uuid; -+ client_uuid = grub_env_get (client_uuid_var); -+ -+ if (client_uuid) -+ { -+ grub_strcpy (suffix, client_uuid); -+ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; -+ } -+ -+ /* By the MAC address. */ -+ -+ /* Add ethernet type */ -+ grub_strcpy (suffix, "01-"); -+ -+ grub_net_hwaddr_to_str (&inf->hwaddress, suffix + 3); -+ -+ char *ptr; -+ for (ptr = suffix; *ptr; ptr++) -+ if (*ptr == ':') -+ *ptr = '-'; -+ -+ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; -+ -+ /* By IP address */ -+ -+ switch ((&inf->address)->type) -+ { -+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4: -+ { -+ grub_uint32_t n = grub_be_to_cpu32 ((&inf->address)->ipv4); -+ grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%02X%02X%02X%02X", \ -+ ((n >> 24) & 0xff), ((n >> 16) & 0xff), \ -+ ((n >> 8) & 0xff), ((n >> 0) & 0xff)); -+ -+ if (search_through (8, 1) == 0) return GRUB_ERR_NONE; -+ break; -+ } -+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6: -+ { -+ char buf[GRUB_NET_MAX_STR_ADDR_LEN]; -+ struct grub_net_network_level_address base; -+ base.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; -+ grub_memcpy (&base.ipv6, ((&inf->address)->ipv6), 16); -+ grub_net_addr_to_str (&base, buf); -+ -+ for (ptr = buf; *ptr; ptr++) -+ if (*ptr == ':') -+ *ptr = '-'; -+ -+ grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%s", buf); -+ if (search_through (1, 0) == 0) return GRUB_ERR_NONE; -+ break; -+ } -+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV: -+ return grub_error (GRUB_ERR_BUG, "shouldn't reach here"); -+ default: -+ return grub_error (GRUB_ERR_BUG, -+ "unsupported address type %d", (&inf->address)->type); -+ } -+ } -+ -+ /* Remove the remaining minus sign at the end. */ -+ config[config_len] = '\0'; -+ -+ return GRUB_ERR_NONE; -+} -+ - static struct grub_preboot *fini_hnd; - - static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute; -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 394bfbea868..9ef98481f70 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -33,6 +33,7 @@ - #include - #include - #include -+#include - #ifdef GRUB_MACHINE_IEEE1275 - #include - #endif -@@ -365,10 +366,19 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), - - prefix = grub_env_get ("prefix"); - if (prefix) -- { -- config = grub_xasprintf ("%s/grub.cfg", prefix); -- if (! config) -- goto quit; -+ { -+ grub_size_t config_len; -+ config_len = grub_strlen (prefix) + -+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -+ config = grub_malloc (config_len); -+ -+ if (! config) -+ goto quit; -+ -+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); -+ -+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -+ grub_net_search_configfile (config); - - grub_enter_normal_mode (config); - grub_free (config); -diff --git a/include/grub/net.h b/include/grub/net.h -index 556c54e579f..ff6d347f7da 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -578,4 +578,7 @@ extern char *grub_net_default_server; - - #define VLANTAG_IDENTIFIER 0x8100 - -+grub_err_t -+grub_net_search_configfile (char *config); -+ - #endif /* ! GRUB_NET_HEADER */ diff --git a/0036-Fix-margins.patch b/0027-Fix-margins.patch similarity index 97% rename from 0036-Fix-margins.patch rename to 0027-Fix-margins.patch index 9be1731..baa10ed 100644 --- a/0036-Fix-margins.patch +++ b/0027-Fix-margins.patch @@ -8,7 +8,7 @@ Subject: [PATCH] Fix margins 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index ecc60f99fc3..0e43f2c10cc 100644 +index 6a57376fa80..cbd62f714cb 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -333,17 +333,15 @@ grub_menu_init_page (int nested, int edit, diff --git a/0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch b/0028-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch similarity index 95% rename from 0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch rename to 0028-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch index 3a37839..7932180 100644 --- a/0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch +++ b/0028-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 0e43f2c10cc..537d4bf86ff 100644 +index cbd62f714cb..26e9e82042a 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -334,7 +334,7 @@ grub_menu_init_page (int nested, int edit, diff --git a/0038-Enable-pager-by-default.-985860.patch b/0029-Enable-pager-by-default.-985860.patch similarity index 100% rename from 0038-Enable-pager-by-default.-985860.patch rename to 0029-Enable-pager-by-default.-985860.patch diff --git a/0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch b/0030-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch similarity index 96% rename from 0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch rename to 0030-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch index 93233bc..7e9e829 100644 --- a/0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch +++ b/0030-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 537d4bf86ff..452d55bf9ff 100644 +index 26e9e82042a..4895ffe7d1d 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -157,7 +157,7 @@ print_message (int nested, int edit, struct grub_term_output *term, int dry_run) diff --git a/0040-Don-t-say-GNU-Linux-in-generated-menus.patch b/0031-Don-t-say-GNU-Linux-in-generated-menus.patch similarity index 95% rename from 0040-Don-t-say-GNU-Linux-in-generated-menus.patch rename to 0031-Don-t-say-GNU-Linux-in-generated-menus.patch index ced2560..db2a8b5 100644 --- a/0040-Don-t-say-GNU-Linux-in-generated-menus.patch +++ b/0031-Don-t-say-GNU-Linux-in-generated-menus.patch @@ -9,7 +9,7 @@ Subject: [PATCH] Don't say "GNU/Linux" in generated menus. 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index ceb413fc2e3..2b402d85a52 100644 +index ad2ac4b078d..4fc58c83304 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" @@ -25,7 +25,7 @@ index ceb413fc2e3..2b402d85a52 100644 fi diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index 96179ea613c..47e0d3f5cd6 100644 +index 3b1f4704921..ada20775a14 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" diff --git a/0041-Don-t-draw-a-border-around-the-menu.patch b/0032-Don-t-draw-a-border-around-the-menu.patch similarity index 98% rename from 0041-Don-t-draw-a-border-around-the-menu.patch rename to 0032-Don-t-draw-a-border-around-the-menu.patch index e5d11ac..31a973e 100644 --- a/0041-Don-t-draw-a-border-around-the-menu.patch +++ b/0032-Don-t-draw-a-border-around-the-menu.patch @@ -9,7 +9,7 @@ It looks cleaner without it. 1 file changed, 43 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 452d55bf9ff..1ed2bd92cf8 100644 +index 4895ffe7d1d..e72ed438ba3 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -108,47 +108,6 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right, diff --git a/0042-Use-the-standard-margin-for-the-timeout-string.patch b/0033-Use-the-standard-margin-for-the-timeout-string.patch similarity index 97% rename from 0042-Use-the-standard-margin-for-the-timeout-string.patch rename to 0033-Use-the-standard-margin-for-the-timeout-string.patch index c6c770c..49a382d 100644 --- a/0042-Use-the-standard-margin-for-the-timeout-string.patch +++ b/0033-Use-the-standard-margin-for-the-timeout-string.patch @@ -9,7 +9,7 @@ So that it aligns with the other messages 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 1ed2bd92cf8..7681f7d2893 100644 +index e72ed438ba3..ca135624356 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -372,7 +372,7 @@ grub_menu_init_page (int nested, int edit, diff --git a/0043-Add-.eh_frame-to-list-of-relocations-stripped.patch b/0034-Add-.eh_frame-to-list-of-relocations-stripped.patch similarity index 96% rename from 0043-Add-.eh_frame-to-list-of-relocations-stripped.patch rename to 0034-Add-.eh_frame-to-list-of-relocations-stripped.patch index 4ab92e5..ed48c5c 100644 --- a/0043-Add-.eh_frame-to-list-of-relocations-stripped.patch +++ b/0034-Add-.eh_frame-to-list-of-relocations-stripped.patch @@ -8,7 +8,7 @@ Subject: [PATCH] Add .eh_frame to list of relocations stripped 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common -index 6cd71cbb2ab..4ba729e14d8 100644 +index 2a1a886f6d5..191b1a70c6b 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding diff --git a/0045-Don-t-require-a-password-to-boot-entries-generated-b.patch b/0035-Don-t-require-a-password-to-boot-entries-generated-b.patch similarity index 96% rename from 0045-Don-t-require-a-password-to-boot-entries-generated-b.patch rename to 0035-Don-t-require-a-password-to-boot-entries-generated-b.patch index c737029..fb0e197 100644 --- a/0045-Don-t-require-a-password-to-boot-entries-generated-b.patch +++ b/0035-Don-t-require-a-password-to-boot-entries-generated-b.patch @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 2b402d85a52..d35b0f406bc 100644 +index 4fc58c83304..635d2fe0cd3 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -26,7 +26,7 @@ datarootdir="@datarootdir@" diff --git a/0046-Don-t-emit-Booting-.-message.patch b/0036-Don-t-emit-Booting-.-message.patch similarity index 87% rename from 0046-Don-t-emit-Booting-.-message.patch rename to 0036-Don-t-emit-Booting-.-message.patch index 63d1812..4133b52 100644 --- a/0046-Don-t-emit-Booting-.-message.patch +++ b/0036-Don-t-emit-Booting-.-message.patch @@ -14,10 +14,10 @@ Signed-off-by: Peter Jones 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 9175ad297d8..783bde55b9e 100644 +index d7a222e681b..37d753d8081 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c -@@ -839,12 +839,14 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) +@@ -838,12 +838,14 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) /* Callback invoked immediately before a menu entry is executed. */ static void @@ -34,10 +34,10 @@ index 9175ad297d8..783bde55b9e 100644 /* Callback invoked when a default menu entry executed because of a timeout diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c -index cdf3590a364..5785f67ee1c 100644 +index 50eef918cf6..de64a367c4e 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c -@@ -1167,9 +1167,6 @@ run (struct screen *screen) +@@ -1176,9 +1176,6 @@ run (struct screen *screen) char *dummy[1] = { NULL }; grub_cls (); diff --git a/0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch b/0037-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch similarity index 99% rename from 0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch rename to 0037-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch index 8c1bd8f..7939965 100644 --- a/0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch +++ b/0037-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch @@ -122,10 +122,10 @@ Replace a bunch of machine generated ones with ones that look nicer. create mode 100644 util/grub-sparc64-setup.8 diff --git a/configure.ac b/configure.ac -index d283af64c8c..8df400e0a8b 100644 +index c0103b30d4e..b8c4d52dfd1 100644 --- a/configure.ac +++ b/configure.ac -@@ -74,6 +74,29 @@ grub_TRANSFORM([grub-set-default]) +@@ -77,6 +77,29 @@ grub_TRANSFORM([grub-set-default]) grub_TRANSFORM([grub-sparc64-setup]) grub_TRANSFORM([grub-render-label]) grub_TRANSFORM([grub-file]) @@ -156,7 +156,7 @@ index d283af64c8c..8df400e0a8b 100644 # Optimization flag. Allow user to override. if test "x$TARGET_CFLAGS" = x; then diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index 46c4e95e2fa..58d7d9540be 100644 +index 8f1485d52a5..b909f2c073a 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -11,7 +11,6 @@ EXTRA_DIST += unicode @@ -498,7 +498,7 @@ index ad25c8ab753..00000000000 -[SEE ALSO] -.BR grub-menulst2cfg (8) diff --git a/gentpl.py b/gentpl.py -index 387588c0589..f05812eace3 100644 +index c86550d4f9e..2cba0bbbd6f 100644 --- a/gentpl.py +++ b/gentpl.py @@ -805,10 +805,7 @@ def manpage(defn, adddeps): diff --git a/0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch b/0038-use-fw_path-prefix-when-fallback-searching-for-grub-.patch similarity index 97% rename from 0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch rename to 0038-use-fw_path-prefix-when-fallback-searching-for-grub-.patch index 65b8855..985205c 100644 --- a/0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch +++ b/0038-use-fw_path-prefix-when-fallback-searching-for-grub-.patch @@ -17,7 +17,7 @@ Signed-off-by: Mark Salter 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 7f61c5b618b..8add30e605f 100644 +index ec1cd257397..d85f7598d23 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -349,7 +349,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), diff --git a/0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch b/0039-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch similarity index 77% rename from 0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch rename to 0039-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch index 45a0982..61dd5ca 100644 --- a/0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch +++ b/0039-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Try mac/guid/etc before grub.cfg on tftp config files. Signed-off-by: Peter Jones --- - grub-core/normal/main.c | 84 ++++++++++++++++++++++++++----------------------- - 1 file changed, 45 insertions(+), 39 deletions(-) + grub-core/normal/main.c | 97 ++++++++++++++++++++++++++----------------------- + 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 8add30e605f..d93bee613ac 100644 +index d85f7598d23..1e509fceb91 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -347,53 +347,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -347,61 +347,66 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), /* Guess the config filename. It is necessary to make CONFIG static, so that it won't get broken by longjmp. */ char *config; @@ -41,25 +41,39 @@ index 8add30e605f..d93bee613ac 100644 - } - } + const char *prefix; ++ const char *net_search_cfg; ++ int disable_net_search = 0; + prefix = grub_env_get ("fw_path"); if (! prefix) prefix = grub_env_get ("prefix"); ++ ++ net_search_cfg = grub_env_get ("feature_net_search_cfg"); ++ if (net_search_cfg && net_search_cfg[0] == 'n') ++ disable_net_search = 1; + if (prefix) { - grub_size_t config_len; +- int disable_net_search = 0; +- const char *net_search_cfg; +- - config_len = grub_strlen (prefix) + -- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); +- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); - config = grub_malloc (config_len); - -- if (! config) +- if (!config) - goto quit; - - grub_snprintf (config, config_len, "%s/grub.cfg", prefix); - - if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -- grub_net_search_configfile (config); +- net_search_cfg = grub_env_get ("feature_net_search_cfg"); +- if (net_search_cfg && net_search_cfg[0] == 'n') +- disable_net_search = 1; +- + if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 && + !disable_net_search) +- grub_net_search_config_file (config); + { + grub_size_t config_len; + config_len = grub_strlen (prefix) + diff --git a/0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch b/0040-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch similarity index 96% rename from 0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch rename to 0040-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch index 6acd50e..ef0b0f4 100644 --- a/0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch +++ b/0040-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index d35b0f406bc..d12d2d784dc 100644 +index 635d2fe0cd3..fed73271478 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -29,7 +29,8 @@ export TEXTDOMAINDIR="@localedir@" diff --git a/0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch b/0041-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch similarity index 93% rename from 0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch rename to 0041-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch index fc29633..3e2d3ae 100644 --- a/0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch +++ b/0041-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch @@ -10,10 +10,10 @@ Signed-off-by: Peter Jones 1 file changed, 8 insertions(+) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 1001a12232b..1a4a57898f9 100644 +index 301d1ac229a..0f6505bf3b6 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in -@@ -249,6 +249,14 @@ version_test_gt () +@@ -253,6 +253,14 @@ version_test_gt () *.old:*.old) ;; *.old:*) version_test_gt_a="`echo "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;; *:*.old) version_test_gt_b="`echo "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;; diff --git a/0055-Try-prefix-if-fw_path-doesn-t-work.patch b/0042-Try-prefix-if-fw_path-doesn-t-work.patch similarity index 85% rename from 0055-Try-prefix-if-fw_path-doesn-t-work.patch rename to 0042-Try-prefix-if-fw_path-doesn-t-work.patch index 6c167e9..59489bd 100644 --- a/0055-Try-prefix-if-fw_path-doesn-t-work.patch +++ b/0042-Try-prefix-if-fw_path-doesn-t-work.patch @@ -7,10 +7,10 @@ Related: rhbz#1148652 Signed-off-by: Peter Jones --- - grub-core/kern/ieee1275/init.c | 28 +++++----- + grub-core/kern/ieee1275/init.c | 28 +++++---- grub-core/net/net.c | 2 +- - grub-core/normal/main.c | 120 ++++++++++++++++++++--------------------- - 3 files changed, 75 insertions(+), 75 deletions(-) + grub-core/normal/main.c | 134 ++++++++++++++++++++--------------------- + 3 files changed, 82 insertions(+), 82 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index e71d1584164..0cd2a627231 100644 @@ -56,10 +56,10 @@ index e71d1584164..0cd2a627231 100644 } diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 06454564b8f..4b7972b8e7e 100644 +index 4d3eb5c1a52..0ef148f4adc 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -1850,7 +1850,7 @@ grub_net_search_configfile (char *config) +@@ -1869,7 +1869,7 @@ grub_net_search_config_file (char *config) /* Remove the remaining minus sign at the end. */ config[config_len] = '\0'; @@ -69,10 +69,10 @@ index 06454564b8f..4b7972b8e7e 100644 static struct grub_preboot *fini_hnd; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index d93bee613ac..2fe6743399d 100644 +index 1e509fceb91..d5968797f4f 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -337,74 +337,72 @@ grub_enter_normal_mode (const char *config) +@@ -337,81 +337,79 @@ grub_enter_normal_mode (const char *config) grub_boot_time ("Exiting normal mode"); } @@ -82,12 +82,19 @@ index d93bee613ac..2fe6743399d 100644 + char *config; + const char *prefix; + grub_err_t err = GRUB_ERR_FILE_NOT_FOUND; ++ const char *net_search_cfg; ++ int disable_net_search = 0; + + prefix = grub_env_get (variable); + if (!prefix) + return GRUB_ERR_FILE_NOT_FOUND; + -+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) ++ net_search_cfg = grub_env_get ("feature_net_search_cfg"); ++ if (net_search_cfg && net_search_cfg[0] == 'n') ++ disable_net_search = 1; ++ ++ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 && ++ !disable_net_search) + { + grub_size_t config_len; + config_len = grub_strlen (prefix) + @@ -98,7 +105,7 @@ index d93bee613ac..2fe6743399d 100644 + return GRUB_ERR_FILE_NOT_FOUND; + + grub_snprintf (config, config_len, "%s/grub.cfg", prefix); -+ err = grub_net_search_configfile (config); ++ err = grub_net_search_config_file (config); + } + + if (err != GRUB_ERR_NONE) @@ -135,14 +142,21 @@ index d93bee613ac..2fe6743399d 100644 - so that it won't get broken by longjmp. */ - char *config; - const char *prefix; +- const char *net_search_cfg; +- int disable_net_search = 0; - - prefix = grub_env_get ("fw_path"); - if (! prefix) - prefix = grub_env_get ("prefix"); - +- net_search_cfg = grub_env_get ("feature_net_search_cfg"); +- if (net_search_cfg && net_search_cfg[0] == 'n') +- disable_net_search = 1; +- - if (prefix) - { -- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) +- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 && +- !disable_net_search) - { - grub_size_t config_len; - config_len = grub_strlen (prefix) + diff --git a/0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch b/0043-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch similarity index 93% rename from 0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch rename to 0043-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch index bfebe38..fce5478 100644 --- a/0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch +++ b/0043-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch @@ -13,21 +13,23 @@ Resolves rhbz#1124074 Signed-off-by: Robert Marshall [pjones: fix --enable-rpm-sort configure option] Signed-off-by: Peter Jones +[thierry.vignaud: fix build with rpm-4.16] +Signed-off-by: Thierry Vignaud --- - configure.ac | 29 +++++ + configure.ac | 38 +++++++ Makefile.util.def | 16 +++ util/grub-rpm-sort.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++ util/grub-mkconfig_lib.in | 11 +- util/grub-rpm-sort.8 | 12 ++ - 5 files changed, 348 insertions(+), 1 deletion(-) + 5 files changed, 357 insertions(+), 1 deletion(-) create mode 100644 util/grub-rpm-sort.c create mode 100644 util/grub-rpm-sort.8 diff --git a/configure.ac b/configure.ac -index 8df400e0a8b..6927615819b 100644 +index b8c4d52dfd1..ac84a8ccf69 100644 --- a/configure.ac +++ b/configure.ac -@@ -69,6 +69,7 @@ grub_TRANSFORM([grub-mkrelpath]) +@@ -72,6 +72,7 @@ grub_TRANSFORM([grub-mkrelpath]) grub_TRANSFORM([grub-mkrescue]) grub_TRANSFORM([grub-probe]) grub_TRANSFORM([grub-reboot]) @@ -35,7 +37,7 @@ index 8df400e0a8b..6927615819b 100644 grub_TRANSFORM([grub-script-check]) grub_TRANSFORM([grub-set-default]) grub_TRANSFORM([grub-sparc64-setup]) -@@ -92,6 +93,7 @@ grub_TRANSFORM([grub-mkrescue.1]) +@@ -95,6 +96,7 @@ grub_TRANSFORM([grub-mkrescue.1]) grub_TRANSFORM([grub-mkstandalone.3]) grub_TRANSFORM([grub-ofpathname.3]) grub_TRANSFORM([grub-probe.3]) @@ -43,7 +45,7 @@ index 8df400e0a8b..6927615819b 100644 grub_TRANSFORM([grub-reboot.3]) grub_TRANSFORM([grub-render-label.3]) grub_TRANSFORM([grub-script-check.3]) -@@ -1802,6 +1804,33 @@ fi +@@ -1860,6 +1862,42 @@ fi AC_SUBST([LIBDEVMAPPER]) @@ -72,16 +74,25 @@ index 8df400e0a8b..6927615819b 100644 + [Define to 1 if you have the rpm library.]) +fi + ++if test x"$LIBRPM" = x ; then ++ # Check for rpm library. ++ AC_CHECK_LIB([rpmio], [rpmvercmp], [], ++ [rpm_sort_excuse="rpmio missing rpmvercmp"]) ++ LIBRPM="-lrpmio"; ++ AC_DEFINE([HAVE_RPMIO], [1], ++ [Define to 1 if you have the rpm library.]) ++fi ++ +AC_SUBST([LIBRPM]) + LIBGEOM= if test x$host_kernel = xkfreebsd; then AC_CHECK_LIB([geom], [geom_gettree], [], diff --git a/Makefile.util.def b/Makefile.util.def -index 1f298d05f3d..843ce092b94 100644 +index 2c9b283a230..ba4cf4b29b0 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -696,6 +696,22 @@ program = { +@@ -703,6 +703,22 @@ program = { ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -392,7 +403,7 @@ index 00000000000..f33bd1ed568 + return 0; +} diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 1a4a57898f9..113a41f9409 100644 +index 0f6505bf3b6..42c2ea9ba50 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -33,6 +33,9 @@ fi @@ -403,9 +414,9 @@ index 1a4a57898f9..113a41f9409 100644 + grub_rpm_sort="${sbindir}/@grub_rpm_sort@" +fi - if which gettext >/dev/null 2>/dev/null; then + if command -v gettext >/dev/null; then : -@@ -214,6 +217,12 @@ version_sort () +@@ -218,6 +221,12 @@ version_sort () esac } @@ -418,7 +429,7 @@ index 1a4a57898f9..113a41f9409 100644 version_test_numeric () { version_test_numeric_a="$1" -@@ -230,7 +239,7 @@ version_test_numeric () +@@ -234,7 +243,7 @@ version_test_numeric () version_test_numeric_a="$version_test_numeric_b" version_test_numeric_b="$version_test_numeric_c" fi diff --git a/0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch b/0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch deleted file mode 100644 index b8dbff5..0000000 --- a/0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Mon, 30 Jun 2014 14:16:46 -0400 -Subject: [PATCH] Don't munge raw spaces when we're doing our cmdline escaping - (#923374) - -Signed-off-by: Peter Jones ---- - grub-core/lib/cmdline.c | 11 +---------- - 1 file changed, 1 insertion(+), 10 deletions(-) - -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index e0fb0a9e48a..8e2294d8ff6 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -98,16 +98,7 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - while (*c) - { -- if (*c == ' ') -- { -- *buf++ = '\\'; -- *buf++ = 'x'; -- *buf++ = '2'; -- *buf++ = '0'; -- c++; -- continue; -- } -- else if (*c == '\\' && *(c+1) == 'x' && -+ if (*c == '\\' && *(c+1) == 'x' && - is_hex(*(c+2)) && is_hex(*(c+3))) - { - *buf++ = *c++; diff --git a/0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch b/0044-Make-grub2-mkconfig-construct-titles-that-look-like-.patch similarity index 98% rename from 0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch rename to 0044-Make-grub2-mkconfig-construct-titles-that-look-like-.patch index 635a234..4c474e4 100644 --- a/0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch +++ b/0044-Make-grub2-mkconfig-construct-titles-that-look-like-.patch @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index d12d2d784dc..12a20c9ad73 100644 +index fed73271478..2e59f3b4197 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -78,6 +78,32 @@ case x"$GRUB_FS" in diff --git a/0060-Add-friendly-grub2-password-config-tool-985962.patch b/0045-Add-friendly-grub2-password-config-tool-985962.patch similarity index 96% rename from 0060-Add-friendly-grub2-password-config-tool-985962.patch rename to 0045-Add-friendly-grub2-password-config-tool-985962.patch index 5374425..5767794 100644 --- a/0060-Add-friendly-grub2-password-config-tool-985962.patch +++ b/0045-Add-friendly-grub2-password-config-tool-985962.patch @@ -27,10 +27,10 @@ Andy Lutomirski create mode 100644 util/grub.d/01_users.in diff --git a/configure.ac b/configure.ac -index 6927615819b..68501662e8d 100644 +index ac84a8ccf69..9ecd3540bd6 100644 --- a/configure.ac +++ b/configure.ac -@@ -69,6 +69,7 @@ grub_TRANSFORM([grub-mkrelpath]) +@@ -72,6 +72,7 @@ grub_TRANSFORM([grub-mkrelpath]) grub_TRANSFORM([grub-mkrescue]) grub_TRANSFORM([grub-probe]) grub_TRANSFORM([grub-reboot]) @@ -39,10 +39,10 @@ index 6927615819b..68501662e8d 100644 grub_TRANSFORM([grub-script-check]) grub_TRANSFORM([grub-set-default]) diff --git a/Makefile.util.def b/Makefile.util.def -index 843ce092b94..e50436a4987 100644 +index ba4cf4b29b0..1a7dd433e33 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -451,6 +451,12 @@ script = { +@@ -452,6 +452,12 @@ script = { installdir = grubconf; }; @@ -55,7 +55,7 @@ index 843ce092b94..e50436a4987 100644 script = { name = '10_windows'; common = util/grub.d/10_windows.in; -@@ -733,6 +739,13 @@ script = { +@@ -740,6 +746,13 @@ script = { installdir = sbin; }; @@ -70,10 +70,10 @@ index 843ce092b94..e50436a4987 100644 name = grub-mkconfig_lib; common = util/grub-mkconfig_lib.in; diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index c645351dd2a..4e7a875309e 100644 +index 91d761bae80..3e4c6c5240b 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -282,6 +282,8 @@ for i in "${grub_mkconfig_dir}"/* ; do +@@ -279,6 +279,8 @@ for i in "${grub_mkconfig_dir}"/* ; do *~) ;; # emacsen autosave files. FIXME: support other editors */\#*\#) ;; diff --git a/0061-tcp-add-window-scaling-support.patch b/0046-tcp-add-window-scaling-support.patch similarity index 100% rename from 0061-tcp-add-window-scaling-support.patch rename to 0046-tcp-add-window-scaling-support.patch diff --git a/0064-efinet-and-bootp-add-support-for-dhcpv6.patch b/0047-efinet-and-bootp-add-support-for-dhcpv6.patch similarity index 92% rename from 0064-efinet-and-bootp-add-support-for-dhcpv6.patch rename to 0047-efinet-and-bootp-add-support-for-dhcpv6.patch index 0e60b8a..96182c2 100644 --- a/0064-efinet-and-bootp-add-support-for-dhcpv6.patch +++ b/0047-efinet-and-bootp-add-support-for-dhcpv6.patch @@ -5,27 +5,19 @@ Subject: [PATCH] efinet and bootp: add support for dhcpv6 Signed-off-by: Peter Jones --- - grub-core/net/bootp.c | 174 +++++++++++++++++++++++++++++++++++++ - grub-core/net/drivers/efi/efinet.c | 54 ++++++++++-- + grub-core/net/bootp.c | 173 +++++++++++++++++++++++++++++++++++++ + grub-core/net/drivers/efi/efinet.c | 53 ++++++++++-- grub-core/net/net.c | 72 +++++++++++++++ grub-core/net/tftp.c | 4 + include/grub/efi/api.h | 129 +++++++++++++++++++++++++-- include/grub/net.h | 60 +++++++++++++ - 6 files changed, 479 insertions(+), 14 deletions(-) + 6 files changed, 477 insertions(+), 14 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 0e6e41a1699..8c969595a7b 100644 +index e33be51f83b..8d9edaac447 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - #include - - struct grub_dhcp_discover_options -@@ -935,6 +936,179 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), +@@ -902,6 +902,179 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp; @@ -206,16 +198,15 @@ index 0e6e41a1699..8c969595a7b 100644 grub_bootp_init (void) { diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 5388f952ba9..a57189e8bb3 100644 +index 5388f952ba9..173fb63153c 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -18,11 +18,15 @@ +@@ -18,11 +18,14 @@ #include #include +#include #include -+#include #include #include #include @@ -225,7 +216,7 @@ index 5388f952ba9..a57189e8bb3 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -329,7 +333,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -329,7 +332,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, char **path) { struct grub_net_card *card; @@ -234,7 +225,7 @@ index 5388f952ba9..a57189e8bb3 100644 dp = grub_efi_get_device_path (hnd); if (! dp) -@@ -340,14 +344,19 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -340,14 +343,19 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, grub_efi_device_path_t *cdp; struct grub_efi_pxe *pxe; struct grub_efi_pxe_mode *pxe_mode; @@ -255,7 +246,7 @@ index 5388f952ba9..a57189e8bb3 100644 int match; /* EDK2 UEFI PXE driver creates pseudo devices with type IPv4/IPv6 -@@ -356,7 +365,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -356,7 +364,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, devices. We skip them when enumerating cards, so here we need to find matching MAC device. */ @@ -263,7 +254,7 @@ index 5388f952ba9..a57189e8bb3 100644 if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) -@@ -373,16 +381,46 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -373,16 +380,46 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (!match) continue; } @@ -316,10 +307,10 @@ index 5388f952ba9..a57189e8bb3 100644 } } diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 4b7972b8e7e..f24f1fd63f6 100644 +index 0ef148f4adc..22f2689aaeb 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -955,6 +955,78 @@ grub_net_network_level_interface_register (struct grub_net_network_level_interfa +@@ -960,6 +960,78 @@ grub_net_network_level_interface_register (struct grub_net_network_level_interfa grub_net_network_level_interfaces = inter; } @@ -399,38 +390,37 @@ index 4b7972b8e7e..f24f1fd63f6 100644 grub_err_t grub_net_add_ipv4_local (struct grub_net_network_level_interface *inter, diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 7d90bf66e76..a5c5038130a 100644 +index 7f44b30f521..4ab2f5c7357 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c -@@ -379,19 +379,23 @@ tftp_open (struct grub_file *file, const char *filename) - return grub_errno; - } +@@ -358,18 +358,22 @@ tftp_open (struct grub_file *file, const char *filename) + file->not_easily_seekable = 1; + file->data = data; -+ grub_dprintf ("tftp", "resolving address for %s\n", file->device->net->server); ++ grub_dprintf("tftp", "resolving address for %s\n", file->device->net->server); err = grub_net_resolve_address (file->device->net->server, &addr); if (err) { + grub_dprintf("tftp", "Address resolution failed: %d\n", err); - destroy_pq (data); grub_free (data); return err; } -+ grub_dprintf ("tftp", "opening connection\n"); ++ grub_dprintf("tftp", "opening connection\n"); data->sock = grub_net_udp_open (addr, TFTP_SERVER_PORT, tftp_receive, file); if (!data->sock) { -+ grub_dprintf ("tftp", "connection failed\n"); - destroy_pq (data); ++ grub_dprintf("tftp", "connection failed\n"); grub_free (data); return grub_errno; + } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index addcbfa8fb7..d97cdf98c80 100644 +index f1a52210c0c..117469450d3 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -572,10 +572,16 @@ typedef void *grub_efi_handle_t; +@@ -592,10 +592,16 @@ typedef void *grub_efi_handle_t; typedef void *grub_efi_event_t; typedef grub_efi_uint64_t grub_efi_lba_t; typedef grub_efi_uintn_t grub_efi_tpl_t; @@ -451,7 +441,7 @@ index addcbfa8fb7..d97cdf98c80 100644 typedef grub_efi_uint64_t grub_efi_physical_address_t; typedef grub_efi_uint64_t grub_efi_virtual_address_t; -@@ -1450,16 +1456,127 @@ struct grub_efi_simple_text_output_interface +@@ -1474,16 +1480,127 @@ struct grub_efi_simple_text_output_interface }; typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t; @@ -582,7 +572,7 @@ index addcbfa8fb7..d97cdf98c80 100644 typedef struct grub_efi_pxe diff --git a/include/grub/net.h b/include/grub/net.h -index ff6d347f7da..3647012374b 100644 +index 7ae4b6bd805..8a05ec4fe7a 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -447,6 +447,51 @@ struct grub_net_bootp_packet diff --git a/0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch b/0048-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch similarity index 94% rename from 0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch rename to 0048-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch index 00611dc..3ffc50c 100644 --- a/0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch +++ b/0048-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch @@ -23,10 +23,10 @@ Resolves: rhbz#1226325 create mode 100644 util/grub-get-kernel-settings.in diff --git a/configure.ac b/configure.ac -index 68501662e8d..fc3c2b44d60 100644 +index 9ecd3540bd6..281201f671e 100644 --- a/configure.ac +++ b/configure.ac -@@ -62,6 +62,7 @@ grub_TRANSFORM([grub-install]) +@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-install]) grub_TRANSFORM([grub-mkconfig]) grub_TRANSFORM([grub-mkfont]) grub_TRANSFORM([grub-mkimage]) @@ -34,7 +34,7 @@ index 68501662e8d..fc3c2b44d60 100644 grub_TRANSFORM([grub-glue-efi]) grub_TRANSFORM([grub-mklayout]) grub_TRANSFORM([grub-mkpasswd-pbkdf2]) -@@ -79,6 +80,7 @@ grub_TRANSFORM([grub-file]) +@@ -82,6 +83,7 @@ grub_TRANSFORM([grub-file]) grub_TRANSFORM([grub-bios-setup.3]) grub_TRANSFORM([grub-editenv.1]) grub_TRANSFORM([grub-fstest.3]) @@ -43,10 +43,10 @@ index 68501662e8d..fc3c2b44d60 100644 grub_TRANSFORM([grub-install.1]) grub_TRANSFORM([grub-kbdcomp.3]) diff --git a/Makefile.util.def b/Makefile.util.def -index e50436a4987..2215cc759c0 100644 +index 1a7dd433e33..cdd2f51fe4b 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -725,6 +725,13 @@ script = { +@@ -732,6 +732,13 @@ script = { installdir = sbin; }; @@ -214,7 +214,7 @@ index 00000000000..7e87dfccc0e + echo export GRUB_UPDATE_DEFAULT_KERNEL +fi diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 4e7a875309e..6247a0ba850 100644 +index 3e4c6c5240b..60beaaa6962 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -45,6 +45,7 @@ grub_probe="${sbindir}/@grub_probe@" @@ -225,17 +225,17 @@ index 4e7a875309e..6247a0ba850 100644 export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -@@ -158,6 +159,8 @@ if test -f ${sysconfdir}/default/grub ; then +@@ -161,6 +162,8 @@ if test -f ${sysconfdir}/default/grub ; then . ${sysconfdir}/default/grub fi +eval "$("${grub_get_kernel_settings}")" || true + - if [ "x$GRUB_DISABLE_UUID" != "xtrue" ]; then - if [ -z "$GRUB_DEVICE_UUID" ]; then - GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED" + if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then + if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then + GRUB_DISABLE_LINUX_UUID="true" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 12a20c9ad73..55f4aa783cf 100644 +index 2e59f3b4197..0f3c19e30cc 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -111,7 +111,8 @@ linux_entry () @@ -258,7 +258,7 @@ index 12a20c9ad73..55f4aa783cf 100644 echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" else echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -@@ -295,11 +299,15 @@ while [ "x$list" != "x" ] ; do +@@ -299,11 +303,15 @@ while [ "x$list" != "x" ] ; do fi if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then @@ -276,7 +276,7 @@ index 12a20c9ad73..55f4aa783cf 100644 if [ -z "$boot_device_id" ]; then boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" fi -@@ -308,10 +316,15 @@ while [ "x$list" != "x" ] ; do +@@ -312,10 +320,15 @@ while [ "x$list" != "x" ] ; do is_top_level=false fi diff --git a/0067-bz1374141-fix-incorrect-mask-for-ppc64.patch b/0049-bz1374141-fix-incorrect-mask-for-ppc64.patch similarity index 100% rename from 0067-bz1374141-fix-incorrect-mask-for-ppc64.patch rename to 0049-bz1374141-fix-incorrect-mask-for-ppc64.patch diff --git a/0050-Fix-convert-function-to-support-NVMe-devices.patch b/0050-Fix-convert-function-to-support-NVMe-devices.patch deleted file mode 100644 index 0fb6616..0000000 --- a/0050-Fix-convert-function-to-support-NVMe-devices.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 18 Feb 2014 11:34:00 -0500 -Subject: [PATCH] Fix convert function to support NVMe devices - -This is adapted from the patch at -https://bugzilla.redhat.com/show_bug.cgi?id=1019660 , which is against -the now very old version of convert_system_partition_to_system_disk(). - -As such, it certainly not the right thing for upstream, but should -function for now. - -Resolves: rhbz#1019660 - -Signed-off-by: Peter Jones ---- - util/getroot.c | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -diff --git a/util/getroot.c b/util/getroot.c -index 847406fbab0..fa3460d6cd8 100644 ---- a/util/getroot.c -+++ b/util/getroot.c -@@ -153,6 +153,7 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part) - { - #if GRUB_UTIL_FD_STAT_IS_FUNCTIONAL - struct stat st; -+ char *path = xmalloc(PATH_MAX); - - if (stat (os_dev, &st) < 0) - { -@@ -165,6 +166,24 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part) - - *is_part = 0; - -+ if (realpath(os_dev, path)) -+ { -+ if ((strncmp ("/dev/nvme", path, 9) == 0)) -+ { -+ char *p = path + 5; -+ p = strchr(p, 'p'); -+ if (p) -+ { -+ *is_part = 1; -+ *p = '\0'; -+ } -+ return path; -+ } -+ } -+ -+ grub_free (path); -+ *is_part = 0; -+ - if (grub_util_device_is_mapped_stat (&st)) - return grub_util_devmapper_part_to_disk (&st, is_part, os_dev); - diff --git a/0068-Make-grub_fatal-also-backtrace.patch b/0050-Make-grub_fatal-also-backtrace.patch similarity index 95% rename from 0068-Make-grub_fatal-also-backtrace.patch rename to 0050-Make-grub_fatal-also-backtrace.patch index de1de20..3534b05 100644 --- a/0068-Make-grub_fatal-also-backtrace.patch +++ b/0050-Make-grub_fatal-also-backtrace.patch @@ -13,10 +13,10 @@ Subject: [PATCH] Make grub_fatal() also backtrace. create mode 100644 grub-core/lib/arm64/backtrace.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 99466b1e47e..ebc558019cd 100644 +index c15e91943b9..058c88ac3af 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -186,6 +186,9 @@ kernel = { +@@ -188,6 +188,9 @@ kernel = { softdiv = lib/division.c; @@ -27,7 +27,7 @@ index 99466b1e47e..ebc558019cd 100644 i386_xen = kern/i386/dl.c; i386_xen_pvh = kern/i386/dl.c; diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 1c560ea570a..04371ac49f2 100644 +index 63b586d09cb..a3e215155bd 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -24,6 +24,7 @@ @@ -38,7 +38,7 @@ index 1c560ea570a..04371ac49f2 100644 union printf_arg { -@@ -1101,8 +1102,13 @@ grub_xasprintf (const char *fmt, ...) +@@ -1199,8 +1200,13 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected) static void __attribute__ ((noreturn)) grub_abort (void) { diff --git a/0051-Add-grub_util_readlink.patch b/0051-Add-grub_util_readlink.patch deleted file mode 100644 index 060a837..0000000 --- a/0051-Add-grub_util_readlink.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 8 Jul 2019 21:46:52 +0200 -Subject: [PATCH] Add grub_util_readlink() - -Add grub_util_readlink(). This requires pulling in stat and readlink from -gnulib, which pulls in stat and related headers, but after that the -implementation is straightforward. - -Signed-off-by: Peter Jones -Reviewed-by: Adam Jackson ---- - grub-core/osdep/windows/hostdisk.c | 6 ++++++ - include/grub/osdep/hostfile_aros.h | 6 ++++++ - include/grub/osdep/hostfile_unix.h | 6 ++++++ - include/grub/osdep/hostfile_windows.h | 2 ++ - 4 files changed, 20 insertions(+) - -diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c -index 355100789a7..87a106c9b82 100644 ---- a/grub-core/osdep/windows/hostdisk.c -+++ b/grub-core/osdep/windows/hostdisk.c -@@ -365,6 +365,12 @@ grub_util_mkdir (const char *dir) - free (windows_name); - } - -+ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - int - grub_util_rename (const char *from, const char *to) - { -diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h -index a059c0fa40a..161fbb7bdfd 100644 ---- a/include/grub/osdep/hostfile_aros.h -+++ b/include/grub/osdep/hostfile_aros.h -@@ -68,6 +68,12 @@ grub_util_rename (const char *from, const char *to) - return rename (from, to); - } - -+static inline ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - #define grub_util_mkdir(a) mkdir ((a), 0755) - - struct grub_util_fd -diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h -index 9ffe46fa3ca..17cd3aa8b30 100644 ---- a/include/grub/osdep/hostfile_unix.h -+++ b/include/grub/osdep/hostfile_unix.h -@@ -71,6 +71,12 @@ grub_util_rename (const char *from, const char *to) - return rename (from, to); - } - -+static inline ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - #define grub_util_mkdir(a) mkdir ((a), 0755) - - #if defined (__NetBSD__) -diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h -index bf6451b6db4..8c92d0591bb 100644 ---- a/include/grub/osdep/hostfile_windows.h -+++ b/include/grub/osdep/hostfile_windows.h -@@ -41,6 +41,8 @@ typedef struct grub_util_fd_dir *grub_util_fd_dir_t; - - int - grub_util_rename (const char *from, const char *to); -+ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize); - int - grub_util_unlink (const char *name); - void diff --git a/0069-Fix-up-some-man-pages-rpmdiff-noticed.patch b/0051-Fix-up-some-man-pages-rpmdiff-noticed.patch similarity index 96% rename from 0069-Fix-up-some-man-pages-rpmdiff-noticed.patch rename to 0051-Fix-up-some-man-pages-rpmdiff-noticed.patch index 80257e3..f51b62f 100644 --- a/0069-Fix-up-some-man-pages-rpmdiff-noticed.patch +++ b/0051-Fix-up-some-man-pages-rpmdiff-noticed.patch @@ -13,10 +13,10 @@ Subject: [PATCH] Fix up some man pages rpmdiff noticed. create mode 100644 util/grub-syslinux2cfg.1 diff --git a/configure.ac b/configure.ac -index fc3c2b44d60..eb851b8d722 100644 +index 281201f671e..6c16968ad9c 100644 --- a/configure.ac +++ b/configure.ac -@@ -84,6 +84,7 @@ grub_TRANSFORM([grub-get-kernel-settings.3]) +@@ -87,6 +87,7 @@ grub_TRANSFORM([grub-get-kernel-settings.3]) grub_TRANSFORM([grub-glue-efi.3]) grub_TRANSFORM([grub-install.1]) grub_TRANSFORM([grub-kbdcomp.3]) @@ -24,7 +24,7 @@ index fc3c2b44d60..eb851b8d722 100644 grub_TRANSFORM([grub-menulst2cfg.1]) grub_TRANSFORM([grub-mkconfig.1]) grub_TRANSFORM([grub-mkfont.3]) -@@ -102,6 +103,7 @@ grub_TRANSFORM([grub-render-label.3]) +@@ -105,6 +106,7 @@ grub_TRANSFORM([grub-render-label.3]) grub_TRANSFORM([grub-script-check.3]) grub_TRANSFORM([grub-set-default.1]) grub_TRANSFORM([grub-sparc64-setup.3]) diff --git a/0052-Make-editenv-chase-symlinks-including-those-across-d.patch b/0052-Make-editenv-chase-symlinks-including-those-across-d.patch deleted file mode 100644 index 288feba..0000000 --- a/0052-Make-editenv-chase-symlinks-including-those-across-d.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 3 Sep 2014 10:38:00 -0400 -Subject: [PATCH] Make editenv chase symlinks including those across devices. - -This lets us make /boot/grub2/grubenv a symlink to -/boot/efi/EFI/fedora/grubenv even though they're different mount points, -which allows /usr/bin/grub2-editenv to be the same across platforms -(i.e. UEFI vs BIOS). - -Signed-off-by: Peter Jones -Reviewed-by: Adam Jackson ---- - Makefile.util.def | 11 +++++++++++ - util/editenv.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- - 2 files changed, 55 insertions(+), 2 deletions(-) - -diff --git a/Makefile.util.def b/Makefile.util.def -index 8717774d510..1f298d05f3d 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -240,8 +240,19 @@ program = { - - common = util/grub-editenv.c; - common = util/editenv.c; -+ common = util/grub-install-common.c; - common = grub-core/osdep/init.c; -+ common = grub-core/osdep/compress.c; -+ extra_dist = grub-core/osdep/unix/compress.c; -+ extra_dist = grub-core/osdep/basic/compress.c; -+ common = util/mkimage.c; -+ common = util/grub-mkimage32.c; -+ common = util/grub-mkimage64.c; -+ common = grub-core/osdep/config.c; -+ common = util/config.c; -+ common = util/resolve.c; - -+ ldadd = '$(LIBLZMA)'; - ldadd = libgrubmods.a; - ldadd = libgrubgcry.a; - ldadd = libgrubkern.a; -diff --git a/util/editenv.c b/util/editenv.c -index eb2d0c03a98..e61dc1283a4 100644 ---- a/util/editenv.c -+++ b/util/editenv.c -@@ -37,6 +37,7 @@ grub_util_create_envblk_file (const char *name) - FILE *fp; - char *buf; - char *namenew; -+ char *rename_target = xstrdup(name); - - buf = xmalloc (DEFAULT_ENVBLK_SIZE); - -@@ -60,7 +61,48 @@ grub_util_create_envblk_file (const char *name) - free (buf); - fclose (fp); - -- if (grub_util_rename (namenew, name) < 0) -- grub_util_error (_("cannot rename the file %s to %s"), namenew, name); -+ ssize_t size = 1; -+ while (1) -+ { -+ char *linkbuf; -+ ssize_t retsize; -+ -+ linkbuf = xmalloc(size+1); -+ retsize = grub_util_readlink (rename_target, linkbuf, size); -+ if (retsize < 0 && (errno == ENOENT || errno == EINVAL)) -+ { -+ free (linkbuf); -+ break; -+ } -+ else if (retsize < 0) -+ { -+ grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name); -+ free (linkbuf); -+ free (namenew); -+ return; -+ } -+ else if (retsize == size) -+ { -+ free(linkbuf); -+ size += 128; -+ continue; -+ } -+ -+ free (rename_target); -+ linkbuf[retsize] = '\0'; -+ rename_target = linkbuf; -+ } -+ -+ int rc = grub_util_rename (namenew, rename_target); -+ if (rc < 0 && errno == EXDEV) -+ { -+ rc = grub_install_copy_file (namenew, rename_target, 1); -+ grub_util_unlink (namenew); -+ } -+ -+ if (rc < 0) -+ grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name); -+ - free (namenew); -+ free (rename_target); - } diff --git a/0071-Make-our-info-pages-say-grub2-where-appropriate.patch b/0052-Make-our-info-pages-say-grub2-where-appropriate.patch similarity index 88% rename from 0071-Make-our-info-pages-say-grub2-where-appropriate.patch rename to 0052-Make-our-info-pages-say-grub2-where-appropriate.patch index eea4e6f..e093067 100644 --- a/0071-Make-our-info-pages-say-grub2-where-appropriate.patch +++ b/0052-Make-our-info-pages-say-grub2-where-appropriate.patch @@ -9,11 +9,11 @@ time. Signed-off-by: Peter Jones --- docs/grub-dev.texi | 4 +- - docs/grub.texi | 318 ++++++++++++++++++++++++++--------------------------- - 2 files changed, 161 insertions(+), 161 deletions(-) + docs/grub.texi | 323 ++++++++++++++++++++++++++++------------------------- + 2 files changed, 172 insertions(+), 155 deletions(-) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi -index ee389fd83c3..e3fed7312a3 100644 +index a834b3a9c32..a55af53fd45 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -1,7 +1,7 @@ @@ -35,7 +35,7 @@ index ee389fd83c3..e3fed7312a3 100644 @setchapternewpage odd diff --git a/docs/grub.texi b/docs/grub.texi -index 221064b5679..960e5f3ba41 100644 +index eeb3118ebde..aa3a7de9d4f 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1,7 +1,7 @@ @@ -212,7 +212,7 @@ index 221064b5679..960e5f3ba41 100644 # @kbd{umount /mnt} @end group @end example -@@ -689,16 +689,16 @@ floppy instead of exposing the USB drive as a hard disk (they call it +@@ -689,30 +689,37 @@ floppy instead of exposing the USB drive as a hard disk (they call it @example # @kbd{losetup /dev/loop0 /dev/sdb1} # @kbd{mount /dev/loop0 /mnt/usb} @@ -223,17 +223,14 @@ index 221064b5679..960e5f3ba41 100644 This install doesn't conflict with standard install as long as they are in separate directories. --Note that @command{grub-install} is actually just a shell script and the --real task is done by other tools such as @command{grub-mkimage}. Therefore, +Note that @command{grub2-install} is actually just a shell script and the +real task is done by other tools such as @command{grub2-mkimage}. Therefore, - you may run those commands directly to install GRUB, without using --@command{grub-install}. Don't do that, however, unless you are very familiar ++you may run those commands directly to install GRUB, without using +@command{grub2-install}. Don't do that, however, unless you are very familiar - with the internals of GRUB. Installing a boot loader on a running OS may be - extremely dangerous. - -@@ -706,20 +706,20 @@ On EFI systems for fixed disk install you have to mount EFI System Partition. ++with the internals of GRUB. Installing a boot loader on a running OS may be ++extremely dangerous. ++ + On EFI systems for fixed disk install you have to mount EFI System Partition. If you mount it at @file{/boot/efi} then you don't need any special arguments: @example @@ -257,7 +254,7 @@ index 221064b5679..960e5f3ba41 100644 @end example @node Making a GRUB bootable CD-ROM -@@ -739,10 +739,10 @@ usually also need to include a configuration file @file{grub.cfg} and some +@@ -732,10 +739,10 @@ usually also need to include a configuration file @file{grub.cfg} and some other GRUB modules. To make a simple generic GRUB rescue CD, you can use the @@ -270,7 +267,7 @@ index 221064b5679..960e5f3ba41 100644 @end example You will often need to include other files in your image. To do this, first -@@ -765,7 +765,7 @@ directory @file{iso/}. +@@ -758,7 +765,7 @@ directory @file{iso/}. Finally, make the image: @example @@ -279,7 +276,7 @@ index 221064b5679..960e5f3ba41 100644 @end example This produces a file named @file{grub.iso}, which then can be burned -@@ -781,7 +781,7 @@ storage devices. +@@ -774,7 +781,7 @@ storage devices. @node Device map @section The map between BIOS drives and OS devices @@ -288,7 +285,7 @@ index 221064b5679..960e5f3ba41 100644 etc.) read it to map BIOS drives to OS devices. This file consists of lines like this: -@@ -1225,23 +1225,23 @@ need to write the whole thing by hand. +@@ -1254,23 +1261,23 @@ need to write the whole thing by hand. @node Simple configuration @section Simple configuration handling @@ -317,7 +314,7 @@ index 221064b5679..960e5f3ba41 100644 valid POSIX shell input; normally, it will just be a sequence of @samp{KEY=value} lines, but if the value contains spaces or other special characters then it must be quoted. For example: -@@ -1279,7 +1279,7 @@ works it's not recommended since titles often contain unstable device names +@@ -1308,7 +1315,7 @@ works it's not recommended since titles often contain unstable device names and may be translated If you set this to @samp{saved}, then the default menu entry will be that @@ -326,7 +323,7 @@ index 221064b5679..960e5f3ba41 100644 the environment block, which may not be available in all situations (@pxref{Environment block}). -@@ -1290,7 +1290,7 @@ If this option is set to @samp{true}, then, when an entry is selected, save +@@ -1319,7 +1326,7 @@ If this option is set to @samp{true}, then, when an entry is selected, save it as a new default entry for use by future runs of GRUB. This is only useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because @samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with @@ -335,7 +332,7 @@ index 221064b5679..960e5f3ba41 100644 This option relies on the environment block, which may not be available in all situations (@pxref{Environment block}). -@@ -1420,7 +1420,7 @@ intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode +@@ -1449,7 +1456,7 @@ intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode @end example @item GRUB_DISABLE_LINUX_UUID @@ -344,7 +341,7 @@ index 221064b5679..960e5f3ba41 100644 universally-unique identifiers (UUIDs) to identify the root filesystem to the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is usually more reliable, but in some cases it may not be appropriate. To -@@ -1442,7 +1442,7 @@ If this option is set to @samp{true}, disable the generation of recovery +@@ -1471,7 +1478,7 @@ If this option is set to @samp{true}, disable the generation of recovery mode menu entries. @item GRUB_DISABLE_UUID @@ -353,7 +350,7 @@ index 221064b5679..960e5f3ba41 100644 universally-unique identifiers (UUIDs) to identify various filesystems to search for files. This is usually more reliable, but in some cases it may not be appropriate. To disable this use of UUIDs, set this option to -@@ -1451,12 +1451,12 @@ not be appropriate. To disable this use of UUIDs, set this option to +@@ -1482,12 +1489,12 @@ not be appropriate. To disable this use of UUIDs, set this option to @item GRUB_VIDEO_BACKEND If graphical video support is required, either because the @samp{gfxterm} graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set, @@ -369,16 +366,22 @@ index 221064b5679..960e5f3ba41 100644 @item GRUB_GFXMODE Set the resolution used on the @samp{gfxterm} graphical terminal. Note that -@@ -1488,7 +1488,7 @@ boot sequence. If you have problems, set this option to @samp{text} and +@@ -1519,20 +1526,20 @@ boot sequence. If you have problems, set this option to @samp{text} and GRUB will tell Linux to boot in normal text mode. @item GRUB_DISABLE_OS_PROBER --Normally, @command{grub-mkconfig} will try to use the external -+Normally, @command{grub2-mkconfig} will try to use the external - @command{os-prober} program, if installed, to discover other operating - systems installed on the same system and generate appropriate menu entries - for them. Set this option to @samp{true} to disable this. -@@ -1498,7 +1498,7 @@ List of space-separated FS UUIDs of filesystems to be ignored from os-prober +-The @command{grub-mkconfig} has a feature to use the external ++The @command{grub2-mkconfig} has a feature to use the external + @command{os-prober} program to discover other operating systems installed on + the same machine and generate appropriate menu entries for them. It is disabled + by default since automatic and silent execution of @command{os-prober}, and + creating boot entries based on that data, is a potential attack vector. Set + this option to @samp{false} to enable this feature in the +-@command{grub-mkconfig} command. ++@command{grub2-mkconfig} command. + + @item GRUB_OS_PROBER_SKIP_LIST + List of space-separated FS UUIDs of filesystems to be ignored from os-prober output. For efi chainloaders it's @@ @item GRUB_DISABLE_SUBMENU @@ -387,7 +390,7 @@ index 221064b5679..960e5f3ba41 100644 the kernel with highest version number and put all other found kernels or alternative menu entries for recovery mode in submenu. For entries returned by @command{os-prober} first entry will be put on top level and all others -@@ -1506,11 +1506,11 @@ in submenu. If this option is set to @samp{y}, flat menu with all entries +@@ -1540,11 +1547,11 @@ in submenu. If this option is set to @samp{true}, flat menu with all entries on top level will be generated instead. Changing this option will require changing existing values of @samp{GRUB_DEFAULT}, @samp{fallback} (@pxref{fallback}) and @samp{default} (@pxref{default}) environment variables as well as saved @@ -402,7 +405,7 @@ index 221064b5679..960e5f3ba41 100644 check for encrypted disks and generate additional commands needed to access them during boot. Note that in this case unattended boot is not possible because GRUB will wait for passphrase to unlock encrypted container. -@@ -1569,7 +1569,7 @@ confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or +@@ -1603,7 +1610,7 @@ confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or @end table @@ -411,7 +414,7 @@ index 221064b5679..960e5f3ba41 100644 edit the scripts in @file{/etc/grub.d} directly. @file{/etc/grub.d/40_custom} is particularly useful for adding entire custom menu entries; simply type the menu entries you want to add at the end of -@@ -1831,7 +1831,7 @@ images as well. +@@ -1864,7 +1871,7 @@ images as well. Mount this partition on/mnt/boot and disable GRUB in all OSes and manually install self-compiled latest GRUB with: @@ -420,7 +423,7 @@ index 221064b5679..960e5f3ba41 100644 In all the OSes install GRUB tools but disable installing GRUB in bootsector, so you'll have menu.lst and grub.cfg available for use. Also disable os-prober -@@ -1841,20 +1841,20 @@ use by setting: +@@ -1874,20 +1881,20 @@ use by setting: in /etc/default/grub @@ -444,7 +447,7 @@ index 221064b5679..960e5f3ba41 100644 @} menuentry "Windows XP" @{ -@@ -1917,15 +1917,15 @@ GRUB supports embedding a configuration file directly into the core image, +@@ -1950,15 +1957,15 @@ GRUB supports embedding a configuration file directly into the core image, so that it is loaded before entering normal mode. This is useful, for example, when it is not straightforward to find the real configuration file, or when you need to debug problems with loading that file. @@ -463,7 +466,7 @@ index 221064b5679..960e5f3ba41 100644 After the embedded configuration file (if any) is executed, GRUB will load the @samp{normal} module (@pxref{normal}), which will then read the real -@@ -1960,13 +1960,13 @@ included in the core image: +@@ -1993,13 +2000,13 @@ included in the core image: @example @group search.fs_label grub root @@ -481,7 +484,7 @@ index 221064b5679..960e5f3ba41 100644 else echo "Could not find an example configuration file!" fi -@@ -2490,7 +2490,7 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38 +@@ -2523,7 +2530,7 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38 @end group @end example @@ -490,7 +493,7 @@ index 221064b5679..960e5f3ba41 100644 server. The grub.cfg file is placed in the same directory as the path output by -@@ -2675,7 +2675,7 @@ team are: +@@ -2717,7 +2724,7 @@ team are: @end table To take full advantage of this function, install GRUB into the MBR @@ -499,7 +502,7 @@ index 221064b5679..960e5f3ba41 100644 If you have a laptop which has a similar feature and not in the above list could you figure your address and contribute? -@@ -2736,7 +2736,7 @@ bytes. +@@ -2778,7 +2785,7 @@ bytes. The sole function of @file{boot.img} is to read the first sector of the core image from a local disk and jump to it. Because of the size restriction, @file{boot.img} cannot understand any file system structure, so @@ -508,7 +511,7 @@ index 221064b5679..960e5f3ba41 100644 core image into @file{boot.img} when installing GRUB. @item diskboot.img -@@ -2766,7 +2766,7 @@ images. +@@ -2808,7 +2815,7 @@ images. @item core.img This is the core image of GRUB. It is built dynamically from the kernel @@ -517,7 +520,7 @@ index 221064b5679..960e5f3ba41 100644 program. Usually, it contains enough modules to access @file{/boot/grub}, and loads everything else (including menu handling, the ability to load target operating systems, and so on) from the file system at run-time. The -@@ -2818,7 +2818,7 @@ GRUB 2 has no single Stage 2 image. Instead, it loads modules from +@@ -2860,7 +2867,7 @@ GRUB 2 has no single Stage 2 image. Instead, it loads modules from In GRUB 2, images for booting from CD-ROM drives are now constructed using @file{cdboot.img} and @file{core.img}, making sure that the core image contains the @samp{iso9660} module. It is usually best to use the @@ -526,7 +529,7 @@ index 221064b5679..960e5f3ba41 100644 @item nbgrub There is as yet no equivalent for @file{nbgrub} in GRUB 2; it was used by -@@ -2974,8 +2974,8 @@ There are two ways to specify files, by @dfn{absolute file name} and by +@@ -3016,8 +3023,8 @@ There are two ways to specify files, by @dfn{absolute file name} and by An absolute file name resembles a Unix absolute file name, using @samp{/} for the directory separator (not @samp{\} as in DOS). One @@ -537,7 +540,7 @@ index 221064b5679..960e5f3ba41 100644 disk. If you omit the device name in an absolute file name, GRUB uses GRUB's @dfn{root device} implicitly. So if you set the root device to, say, @samp{(hd1,1)} by the command @samp{set root=(hd1,1)} (@pxref{set}), -@@ -2983,8 +2983,8 @@ then @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}. +@@ -3025,8 +3032,8 @@ then @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}. On ZFS filesystem the first path component must be @var{volume}@samp{@@}[@var{snapshot}]. @@ -548,7 +551,7 @@ index 221064b5679..960e5f3ba41 100644 @samp{snap-129}. Trailing @samp{@@} after volume name is mandatory even if snapshot name is omitted. -@@ -3387,7 +3387,7 @@ The more recent release of Minix would then be identified as +@@ -3429,7 +3436,7 @@ The more recent release of Minix would then be identified as @samp{other>minix>minix-3.4.0}. This variable is often set by @samp{GRUB_DEFAULT} (@pxref{Simple @@ -557,7 +560,7 @@ index 221064b5679..960e5f3ba41 100644 @node fallback -@@ -3477,7 +3477,7 @@ If this variable is set, it names the language code that the +@@ -3519,7 +3526,7 @@ If this variable is set, it names the language code that the example, French would be named as @samp{fr}, and Simplified Chinese as @samp{zh_CN}. @@ -566,7 +569,7 @@ index 221064b5679..960e5f3ba41 100644 reasonable default for this variable based on the system locale. -@@ -3485,10 +3485,10 @@ reasonable default for this variable based on the system locale. +@@ -3527,10 +3534,10 @@ reasonable default for this variable based on the system locale. @subsection locale_dir If this variable is set, it names the directory where translation files may @@ -579,7 +582,7 @@ index 221064b5679..960e5f3ba41 100644 default for this variable if internationalization is needed and any translation files are available. -@@ -3606,7 +3606,7 @@ input. The default is not to pause output. +@@ -3648,7 +3655,7 @@ input. The default is not to pause output. The location of the @samp{/boot/grub} directory as an absolute file name (@pxref{File name syntax}). This is normally set by GRUB at startup based @@ -588,7 +591,7 @@ index 221064b5679..960e5f3ba41 100644 dynamically loaded from this directory, so it must be set correctly in order for many parts of GRUB to work. -@@ -3697,17 +3697,17 @@ GRUB provides an ``environment block'' which can be used to save a small +@@ -3739,17 +3746,17 @@ GRUB provides an ``environment block'' which can be used to save a small amount of state. The environment block is a preallocated 1024-byte file, which normally lives @@ -609,7 +612,7 @@ index 221064b5679..960e5f3ba41 100644 @samp{GRUB_SAVEDEFAULT} (@pxref{Simple configuration}). -@@ -4398,7 +4398,7 @@ Translate @var{string} into the current language. +@@ -4473,7 +4480,7 @@ Translate @var{string} into the current language. The current language code is stored in the @samp{lang} variable in GRUB's environment (@pxref{lang}). Translation files in MO format are read from @@ -618,7 +621,7 @@ index 221064b5679..960e5f3ba41 100644 @end deffn -@@ -4793,7 +4793,7 @@ Define a user named @var{user} with password @var{clear-password}. +@@ -4868,7 +4875,7 @@ Define a user named @var{user} with password @var{clear-password}. @deffn Command password_pbkdf2 user hashed-password Define a user named @var{user} with password hash @var{hashed-password}. @@ -627,7 +630,7 @@ index 221064b5679..960e5f3ba41 100644 to generate password hashes. @xref{Security}. @end deffn -@@ -5651,8 +5651,8 @@ The @samp{password} (@pxref{password}) and @samp{password_pbkdf2} +@@ -5811,8 +5818,8 @@ The @samp{password} (@pxref{password}) and @samp{password_pbkdf2} which has an associated password. @samp{password} sets the password in plain text, requiring @file{grub.cfg} to be secure; @samp{password_pbkdf2} sets the password hashed using the Password-Based Key Derivation Function @@ -638,7 +641,7 @@ index 221064b5679..960e5f3ba41 100644 In order to enable authentication support, the @samp{superusers} environment variable must be set to a list of usernames, separated by any of spaces, -@@ -5696,7 +5696,7 @@ menuentry "May be run by user1 or a superuser" --users user1 @{ +@@ -5857,7 +5864,7 @@ menuentry "May be run by user1 or a superuser" --users user1 @{ @end group @end example @@ -647,28 +650,26 @@ index 221064b5679..960e5f3ba41 100644 generating configuration files with authentication. You can use @file{/etc/grub.d/40_custom} to add simple superuser authentication, by adding @kbd{set superusers=} and @kbd{password} or @kbd{password_pbkdf2} -@@ -5721,15 +5721,15 @@ verified with a public key currently trusted by GRUB - validation fails, then file @file{foo} cannot be opened. This failure - may halt or otherwise impact the boot process. +@@ -5884,7 +5891,17 @@ may halt or otherwise impact the boot process. --@comment Unfortunately --pubkey is not yet supported by grub-install, --@comment but we should not bring up internal detail grub-mkimage here + An initial trusted public key can be embedded within the GRUB @file{core.img} + using the @code{--pubkey} option to @command{grub-install} +-(@pxref{Invoking grub-install}). ++(@pxref{Invoking grub2-install}). ++ +@comment Unfortunately --pubkey is not yet supported by grub2-install, +@comment but we should not bring up internal detail grub2-mkimage here - @comment in the user guide (as opposed to developer's manual). - - @comment An initial trusted public key can be embedded within the GRUB - @comment @file{core.img} using the @code{--pubkey} option to --@comment @command{grub-mkimage} (@pxref{Invoking grub-install}). Presently it --@comment is necessary to write a custom wrapper around @command{grub-mkimage} --@comment using the @code{--grub-mkimage} flag to @command{grub-install}. ++@comment in the user guide (as opposed to developer's manual). ++ ++@comment An initial trusted public key can be embedded within the GRUB ++@comment @file{core.img} using the @code{--pubkey} option to +@comment @command{grub2-mkimage} (@pxref{Invoking grub2-install}). Presently it +@comment is necessary to write a custom wrapper around @command{grub2-mkimage} +@comment using the @code{--grub-mkimage} flag to @command{grub2-install}. GRUB uses GPG-style detached signatures (meaning that a file @file{foo.sig} will be produced when file @file{foo} is signed), and -@@ -5749,8 +5749,8 @@ gpg --detach-sign /path/to/file +@@ -5904,8 +5921,8 @@ gpg --detach-sign /path/to/file For successful validation of all of GRUB's subcomponents and the loaded OS kernel, they must all be signed. One way to accomplish this is the following (after having already produced the desired @@ -679,7 +680,7 @@ index 221064b5679..960e5f3ba41 100644 @example @group -@@ -5772,7 +5772,7 @@ See also: @ref{check_signatures}, @ref{verify_detached}, @ref{trust}, +@@ -5927,7 +5944,7 @@ See also: @ref{check_signatures}, @ref{verify_detached}, @ref{trust}, Note that internally signature enforcement is controlled by setting the environment variable @code{check_signatures} equal to @code{enforce}. Passing one or more @code{--pubkey} options to @@ -688,7 +689,7 @@ index 221064b5679..960e5f3ba41 100644 equal to @code{enforce} in @file{core.img} prior to processing any configuration files. -@@ -6189,10 +6189,10 @@ Required files are: +@@ -6385,10 +6402,10 @@ Required files are: GRUB's normal start-up procedure involves setting the @samp{prefix} environment variable to a value set in the core image by @@ -701,7 +702,7 @@ index 221064b5679..960e5f3ba41 100644 things GRUB is supposed to do. If, instead, you only get a rescue shell, this usually means that GRUB -@@ -6218,8 +6218,8 @@ normal +@@ -6414,8 +6431,8 @@ normal However, any problem that leaves you in the rescue shell probably means that GRUB was not correctly installed. It may be more useful to try to reinstall @@ -712,7 +713,7 @@ index 221064b5679..960e5f3ba41 100644 @itemize @bullet{} @item -@@ -6231,7 +6231,7 @@ is usually better to use UUIDs or file system labels and avoid depending on +@@ -6427,7 +6444,7 @@ is usually better to use UUIDs or file system labels and avoid depending on drive ordering entirely. @item @@ -721,7 +722,7 @@ index 221064b5679..960e5f3ba41 100644 to a partition but GRUB has already been installed in the master boot record, then the GRUB installation in the partition will be ignored. -@@ -6262,21 +6262,21 @@ entry which claims partition start at block 0. This change will not hamper +@@ -6458,21 +6475,21 @@ entry which claims partition start at block 0. This change will not hamper bootability on other machines. @@ -749,7 +750,7 @@ index 221064b5679..960e5f3ba41 100644 @table @option @item --help -@@ -6292,13 +6292,13 @@ separate partition or a removable disk. +@@ -6488,13 +6505,13 @@ separate partition or a removable disk. If this option is not specified then it defaults to @file{/boot}, so @example @@ -765,7 +766,7 @@ index 221064b5679..960e5f3ba41 100644 @end example Here is an example in which you have a separate @dfn{boot} partition which is -@@ -6306,16 +6306,16 @@ mounted on +@@ -6502,16 +6519,16 @@ mounted on @file{/mnt/boot}: @example @@ -785,7 +786,7 @@ index 221064b5679..960e5f3ba41 100644 extra space in the bootloader embedding area for Reed-Solomon error-correcting codes. This enables GRUB to still boot successfully if some blocks are corrupted. The exact amount of protection offered -@@ -6328,17 +6328,17 @@ installation}) where GRUB does not reside in any unpartitioned space +@@ -6524,17 +6541,17 @@ installation}) where GRUB does not reside in any unpartitioned space outside of the MBR. Disable the Reed-Solomon codes with this option. @end table @@ -808,7 +809,7 @@ index 221064b5679..960e5f3ba41 100644 @table @option @item --help -@@ -6354,17 +6354,17 @@ it to standard output. +@@ -6550,17 +6567,17 @@ it to standard output. @end table @@ -830,7 +831,7 @@ index 221064b5679..960e5f3ba41 100644 @table @option @item -c @var{number} -@@ -6382,23 +6382,23 @@ Length of the salt. Defaults to 64. +@@ -6578,23 +6595,23 @@ Length of the salt. Defaults to 64. @end table @@ -860,7 +861,7 @@ index 221064b5679..960e5f3ba41 100644 @table @option @item --help -@@ -6409,17 +6409,17 @@ Print the version number of GRUB and exit. +@@ -6605,17 +6622,17 @@ Print the version number of GRUB and exit. @end table @@ -882,7 +883,7 @@ index 221064b5679..960e5f3ba41 100644 passed on directly to @command{xorriso} in @command{mkisofs} emulation mode. Options passed to @command{xorriso} will normally be interpreted as @command{mkisofs} options; if the option @samp{--} is used, then anything -@@ -6434,7 +6434,7 @@ mkdir -p disk/boot/grub +@@ -6630,7 +6647,7 @@ mkdir -p disk/boot/grub grub-mkrescue -o grub.iso disk @end example @@ -891,7 +892,7 @@ index 221064b5679..960e5f3ba41 100644 @table @option @item --help -@@ -6462,15 +6462,15 @@ Use @var{file} as the @command{xorriso} program, rather than the built-in +@@ -6658,15 +6675,15 @@ Use @var{file} as the @command{xorriso} program, rather than the built-in default. @item --grub-mkimage=@var{file} @@ -911,7 +912,7 @@ index 221064b5679..960e5f3ba41 100644 system or file system image that GRUB understands, using GRUB's file system drivers via FUSE. (It is only available if FUSE development files were present when GRUB was built.) This has a number of uses: -@@ -6502,13 +6502,13 @@ even if nobody has yet written a FUSE module specifically for that file +@@ -6698,13 +6715,13 @@ even if nobody has yet written a FUSE module specifically for that file system type. @end itemize @@ -927,7 +928,7 @@ index 221064b5679..960e5f3ba41 100644 non-option arguments (if it is given more than one image, it will treat them as a RAID set), and also accepts the following options: -@@ -6530,13 +6530,13 @@ Show debugging output for conditions matching @var{string}. +@@ -6726,13 +6743,13 @@ Show debugging output for conditions matching @var{string}. @item -K prompt|@var{file} @itemx --zfs-key=prompt|@var{file} Load a ZFS encryption key. If you use @samp{prompt} as the argument, @@ -943,7 +944,7 @@ index 221064b5679..960e5f3ba41 100644 root of the supplied file system. If @var{device} is just a number, then it will be treated as a partition -@@ -6554,10 +6554,10 @@ Print verbose messages. +@@ -6750,10 +6767,10 @@ Print verbose messages. @end table @@ -957,7 +958,7 @@ index 221064b5679..960e5f3ba41 100644 or device. @example -@@ -6565,7 +6565,7 @@ grub-probe --target=fs /boot/grub +@@ -6761,7 +6778,7 @@ grub-probe --target=fs /boot/grub grub-probe --target=drive --device /dev/sda1 @end example @@ -966,7 +967,7 @@ index 221064b5679..960e5f3ba41 100644 argument, and also accepts the following options: @table @option -@@ -6578,16 +6578,16 @@ Print the version number of GRUB and exit. +@@ -6774,16 +6791,16 @@ Print the version number of GRUB and exit. @item -d @itemx --device If this option is given, then the non-option argument is a system device @@ -986,7 +987,7 @@ index 221064b5679..960e5f3ba41 100644 @item -t @var{target} @itemx --target=@var{target} -@@ -6640,19 +6640,19 @@ Print verbose messages. +@@ -6836,19 +6853,19 @@ Print verbose messages. @end table diff --git a/0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch b/0053-macos-just-build-chainloader-entries-don-t-try-any-x.patch similarity index 97% rename from 0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch rename to 0053-macos-just-build-chainloader-entries-don-t-try-any-x.patch index 3a761c0..2f3fd13 100644 --- a/0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch +++ b/0053-macos-just-build-chainloader-entries-don-t-try-any-x.patch @@ -20,10 +20,10 @@ Signed-off-by: Peter Jones 1 file changed, 18 insertions(+), 60 deletions(-) diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 9b8f5968e2d..13a3a6bc752 100644 +index 94622481284..9d6ea55bdd3 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in -@@ -42,68 +42,25 @@ if [ -z "${OSPROBED}" ] ; then +@@ -45,68 +45,25 @@ if [ -z "${OSPROBED}" ] ; then fi osx_entry() { @@ -104,7 +104,7 @@ index 9b8f5968e2d..13a3a6bc752 100644 } EOF } -@@ -284,11 +241,12 @@ EOF +@@ -295,11 +252,12 @@ EOF echo "$title_correction_code" ;; macosx) diff --git a/0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch b/0054-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch similarity index 95% rename from 0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch rename to 0054-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch index 41616b0..68dfc1d 100644 --- a/0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch +++ b/0054-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch @@ -24,7 +24,7 @@ Signed-off-by: Jeff Mahoney 2 files changed, 533 insertions(+), 20 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 48bd3d04a5e..6823d9765c4 100644 +index 63203034dfc..f1fff7385b5 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -38,6 +38,9 @@ @@ -36,8 +36,8 @@ index 48bd3d04a5e..6823d9765c4 100644 +#include #include #include - -@@ -78,9 +81,11 @@ struct grub_btrfs_superblock + #include +@@ -79,9 +82,11 @@ struct grub_btrfs_superblock grub_uint64_t generation; grub_uint64_t root_tree; grub_uint64_t chunk_tree; @@ -51,7 +51,7 @@ index 48bd3d04a5e..6823d9765c4 100644 struct grub_btrfs_device this_device; char label[0x100]; grub_uint8_t dummy4[0x100]; -@@ -120,6 +125,7 @@ struct grub_btrfs_data +@@ -121,6 +126,7 @@ struct grub_btrfs_data grub_uint64_t exttree; grub_size_t extsize; struct grub_btrfs_extent_data *extent; @@ -59,7 +59,7 @@ index 48bd3d04a5e..6823d9765c4 100644 }; struct grub_btrfs_chunk_item -@@ -188,6 +194,14 @@ struct grub_btrfs_leaf_descriptor +@@ -191,6 +197,14 @@ struct grub_btrfs_leaf_descriptor } *data; }; @@ -74,7 +74,7 @@ index 48bd3d04a5e..6823d9765c4 100644 struct grub_btrfs_time { grub_int64_t sec; -@@ -233,6 +247,14 @@ struct grub_btrfs_extent_data +@@ -236,6 +250,14 @@ struct grub_btrfs_extent_data #define GRUB_BTRFS_OBJECT_ID_CHUNK 0x100 @@ -89,7 +89,7 @@ index 48bd3d04a5e..6823d9765c4 100644 static grub_disk_addr_t superblock_sectors[] = { 64 * 2, 64 * 1024 * 2, 256 * 1048576 * 2, 1048576ULL * 1048576ULL * 2 }; -@@ -1153,6 +1175,62 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, +@@ -1173,6 +1195,62 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, return GRUB_ERR_NONE; } @@ -152,7 +152,7 @@ index 48bd3d04a5e..6823d9765c4 100644 static struct grub_btrfs_data * grub_btrfs_mount (grub_device_t dev) { -@@ -1188,6 +1266,13 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1208,6 +1286,13 @@ grub_btrfs_mount (grub_device_t dev) data->devices_attached[0].dev = dev; data->devices_attached[0].id = data->sblock.this_device.device_id; @@ -166,7 +166,7 @@ index 48bd3d04a5e..6823d9765c4 100644 return data; } -@@ -1653,6 +1738,91 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key, +@@ -1673,6 +1758,91 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key, return GRUB_ERR_NONE; } @@ -258,7 +258,7 @@ index 48bd3d04a5e..6823d9765c4 100644 static grub_err_t find_path (struct grub_btrfs_data *data, const char *path, struct grub_btrfs_key *key, -@@ -1671,14 +1841,26 @@ find_path (struct grub_btrfs_data *data, +@@ -1691,14 +1861,26 @@ find_path (struct grub_btrfs_data *data, char *origpath = NULL; unsigned symlinks_max = 32; @@ -289,7 +289,7 @@ index 48bd3d04a5e..6823d9765c4 100644 while (1) { while (path[0] == '/') -@@ -1851,9 +2033,21 @@ find_path (struct grub_btrfs_data *data, +@@ -1871,9 +2053,21 @@ find_path (struct grub_btrfs_data *data, path = path_alloc = tmp; if (path[0] == '/') { @@ -314,7 +314,7 @@ index 48bd3d04a5e..6823d9765c4 100644 } continue; } -@@ -2094,18 +2288,10 @@ grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len) +@@ -2114,18 +2308,10 @@ grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len) data->tree, file->offset, buf, len); } @@ -336,7 +336,7 @@ index 48bd3d04a5e..6823d9765c4 100644 grub_be_to_cpu16 (data->sblock.uuid[0]), grub_be_to_cpu16 (data->sblock.uuid[1]), grub_be_to_cpu16 (data->sblock.uuid[2]), -@@ -2114,6 +2300,20 @@ grub_btrfs_uuid (grub_device_t device, char **uuid) +@@ -2134,6 +2320,20 @@ grub_btrfs_uuid (grub_device_t device, char **uuid) grub_be_to_cpu16 (data->sblock.uuid[5]), grub_be_to_cpu16 (data->sblock.uuid[6]), grub_be_to_cpu16 (data->sblock.uuid[7])); @@ -357,7 +357,7 @@ index 48bd3d04a5e..6823d9765c4 100644 grub_btrfs_unmount (data); -@@ -2170,6 +2370,242 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), +@@ -2190,6 +2390,242 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), } #endif @@ -600,7 +600,7 @@ index 48bd3d04a5e..6823d9765c4 100644 static struct grub_fs grub_btrfs_fs = { .name = "btrfs", .fs_dir = grub_btrfs_dir, -@@ -2185,12 +2621,88 @@ static struct grub_fs grub_btrfs_fs = { +@@ -2205,12 +2641,88 @@ static struct grub_fs grub_btrfs_fs = { #endif }; diff --git a/0075-export-btrfs_subvol-and-btrfs_subvolid.patch b/0055-export-btrfs_subvol-and-btrfs_subvolid.patch similarity index 91% rename from 0075-export-btrfs_subvol-and-btrfs_subvolid.patch rename to 0055-export-btrfs_subvol-and-btrfs_subvolid.patch index 5af81e7..d38a6b8 100644 --- a/0075-export-btrfs_subvol-and-btrfs_subvolid.patch +++ b/0055-export-btrfs_subvol-and-btrfs_subvolid.patch @@ -12,10 +12,10 @@ Signed-off-by: Michael Chang 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 6823d9765c4..2d099b18ea1 100644 +index f1fff7385b5..ad1b56b716d 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -2694,6 +2694,8 @@ GRUB_MOD_INIT (btrfs) +@@ -2714,6 +2714,8 @@ GRUB_MOD_INIT (btrfs) subvol_set_env); grub_register_variable_hook ("btrfs_subvolid", subvolid_get_env, subvolid_set_env); diff --git a/0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch b/0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch deleted file mode 100644 index afa3203..0000000 --- a/0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Mon, 16 Mar 2015 16:34:51 -0400 -Subject: [PATCH] Update info with grub.cfg netboot selection order (#1148650) - -Added documentation to the grub info page that specifies the order -netboot clients will use to select a grub configuration file. - -Resolves rhbz#1148650 ---- - docs/grub.texi | 42 ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 42 insertions(+) - -diff --git a/docs/grub.texi b/docs/grub.texi -index 6f524305085..221064b5679 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -2493,6 +2493,48 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38 - Then follow instructions printed out by grub-mknetdir on configuring your DHCP - server. - -+The grub.cfg file is placed in the same directory as the path output by -+grub-mknetdir hereafter referred to as FWPATH. GRUB will search for its -+configuration files in order using the following rules where the appended -+value corresponds to a value on the client machine. -+ -+@example -+@group -+@samp{(FWPATH)}/grub.cfg-@samp{(UUID OF NIC)} -+@samp{(FWPATH)}/grub.cfg-@samp{(MAC ADDRESS OF NIC)} -+@samp{(FWPATH)}/grub.cfg-@samp{(IPv4 OR IPv6 ADDRESS)} -+@samp{(FWPATH)}/grub.cfg -+@end group -+@end example -+ -+The client will only attempt to look up an IPv6 address config once, however, -+it will try the IPv4 multiple times. The concrete example below shows what -+would happen under the IPv4 case. -+ -+@example -+@group -+UUID: 7726a678-7fc0-4853-a4f6-c85ac36a120a -+MAC: 52:54:00:ec:33:81 -+IPV4: 10.0.0.130 (0A000082) -+@end group -+@end example -+ -+@example -+@group -+@samp{(FWPATH)}/grub.cfg-7726a678-7fc0-4853-a4f6-c85ac36a120a -+@samp{(FWPATH)}/grub.cfg-52-54-00-ec-33-81 -+@samp{(FWPATH)}/grub.cfg-0A000082 -+@samp{(FWPATH)}/grub.cfg-0A00008 -+@samp{(FWPATH)}/grub.cfg-0A0000 -+@samp{(FWPATH)}/grub.cfg-0A000 -+@samp{(FWPATH)}/grub.cfg-0A00 -+@samp{(FWPATH)}/grub.cfg-0A0 -+@samp{(FWPATH)}/grub.cfg-0A -+@samp{(FWPATH)}/grub.cfg-0 -+@samp{(FWPATH)}/grub.cfg -+@end group -+@end example -+ - After GRUB has started, files on the TFTP server will be accessible via the - @samp{(tftp)} device. - diff --git a/0076-grub2-btrfs-03-follow_default.patch b/0056-grub2-btrfs-03-follow_default.patch similarity index 89% rename from 0076-grub2-btrfs-03-follow_default.patch rename to 0056-grub2-btrfs-03-follow_default.patch index b28aa78..2b9a136 100644 --- a/0076-grub2-btrfs-03-follow_default.patch +++ b/0056-grub2-btrfs-03-follow_default.patch @@ -8,10 +8,10 @@ Subject: [PATCH] grub2-btrfs-03-follow_default 1 file changed, 76 insertions(+), 31 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 2d099b18ea1..2db89f71ea5 100644 +index ad1b56b716d..113c1f746c9 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -1236,6 +1236,7 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1256,6 +1256,7 @@ grub_btrfs_mount (grub_device_t dev) { struct grub_btrfs_data *data; grub_err_t err; @@ -19,7 +19,7 @@ index 2d099b18ea1..2db89f71ea5 100644 if (!dev->disk) { -@@ -1266,11 +1267,14 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1286,11 +1287,14 @@ grub_btrfs_mount (grub_device_t dev) data->devices_attached[0].dev = dev; data->devices_attached[0].id = data->sblock.this_device.device_id; @@ -38,7 +38,7 @@ index 2d099b18ea1..2db89f71ea5 100644 } return data; -@@ -1835,24 +1839,39 @@ find_path (struct grub_btrfs_data *data, +@@ -1855,24 +1859,39 @@ find_path (struct grub_btrfs_data *data, grub_size_t allocated = 0; struct grub_btrfs_dir_item *direl = NULL; struct grub_btrfs_key key_out; @@ -85,7 +85,7 @@ index 2d099b18ea1..2db89f71ea5 100644 } else { -@@ -1863,15 +1882,23 @@ find_path (struct grub_btrfs_data *data, +@@ -1883,15 +1902,23 @@ find_path (struct grub_btrfs_data *data, while (1) { @@ -118,7 +118,7 @@ index 2d099b18ea1..2db89f71ea5 100644 if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY) { -@@ -1882,7 +1909,9 @@ find_path (struct grub_btrfs_data *data, +@@ -1902,7 +1929,9 @@ find_path (struct grub_btrfs_data *data, if (ctokenlen == 1 && ctoken[0] == '.') { @@ -129,7 +129,7 @@ index 2d099b18ea1..2db89f71ea5 100644 continue; } if (ctokenlen == 2 && ctoken[0] == '.' && ctoken[1] == '.') -@@ -1913,8 +1942,9 @@ find_path (struct grub_btrfs_data *data, +@@ -1933,8 +1962,9 @@ find_path (struct grub_btrfs_data *data, *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; key->object_id = key_out.offset; @@ -141,7 +141,7 @@ index 2d099b18ea1..2db89f71ea5 100644 continue; } -@@ -1983,7 +2013,9 @@ find_path (struct grub_btrfs_data *data, +@@ -2003,7 +2033,9 @@ find_path (struct grub_btrfs_data *data, return err; } @@ -152,7 +152,7 @@ index 2d099b18ea1..2db89f71ea5 100644 if (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK) { struct grub_btrfs_inode inode; -@@ -2033,14 +2065,26 @@ find_path (struct grub_btrfs_data *data, +@@ -2053,14 +2085,26 @@ find_path (struct grub_btrfs_data *data, path = path_alloc = tmp; if (path[0] == '/') { @@ -186,7 +186,7 @@ index 2d099b18ea1..2db89f71ea5 100644 } else { -@@ -2696,6 +2740,7 @@ GRUB_MOD_INIT (btrfs) +@@ -2716,6 +2760,7 @@ GRUB_MOD_INIT (btrfs) subvolid_set_env); grub_env_export ("btrfs_subvol"); grub_env_export ("btrfs_subvolid"); diff --git a/0077-grub2-btrfs-04-grub2-install.patch b/0057-grub2-btrfs-04-grub2-install.patch similarity index 94% rename from 0077-grub2-btrfs-04-grub2-install.patch rename to 0057-grub2-btrfs-04-grub2-install.patch index b490f8d..1a617c2 100644 --- a/0077-grub2-btrfs-04-grub2-install.patch +++ b/0057-grub2-btrfs-04-grub2-install.patch @@ -13,7 +13,7 @@ Subject: [PATCH] grub2-btrfs-04-grub2-install 6 files changed, 54 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 6d9f4e5faa2..5d50dd6f8dc 100644 +index 001b818fe58..caf9b1ccd3f 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -376,6 +376,7 @@ get_btrfs_fs_prefix (const char *mount_path) @@ -38,7 +38,7 @@ index 6d9f4e5faa2..5d50dd6f8dc 100644 else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0) { diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c -index 65effa9f3a7..b637c58efb7 100644 +index 7d6325138ce..46a881530c0 100644 --- a/grub-core/osdep/unix/config.c +++ b/grub-core/osdep/unix/config.c @@ -82,6 +82,19 @@ grub_util_load_config (struct grub_util_config *cfg) @@ -94,10 +94,10 @@ index ebcdd8f5e22..f044a880a76 100644 sizeof ("GRUB_DISTRIBUTOR=") - 1) == 0) { diff --git a/util/grub-install.c b/util/grub-install.c -index 8a55ad4b8dc..0e807b09c36 100644 +index a0babe3eff9..427ae013701 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -819,6 +819,8 @@ fill_core_services (const char *core_services) +@@ -827,6 +827,8 @@ fill_core_services (const char *core_services) free (sysv_plist); } @@ -106,7 +106,7 @@ index 8a55ad4b8dc..0e807b09c36 100644 int main (int argc, char *argv[]) { -@@ -852,6 +854,9 @@ main (int argc, char *argv[]) +@@ -860,6 +862,9 @@ main (int argc, char *argv[]) grub_util_load_config (&config); @@ -116,7 +116,7 @@ index 8a55ad4b8dc..0e807b09c36 100644 if (!bootloader_id && config.grub_distributor) { char *ptr; -@@ -1344,6 +1349,16 @@ main (int argc, char *argv[]) +@@ -1352,6 +1357,16 @@ main (int argc, char *argv[]) fprintf (load_cfg_f, "set debug='%s'\n", debug_image); } diff --git a/0058-Handle-rssd-storage-devices.patch b/0058-Handle-rssd-storage-devices.patch deleted file mode 100644 index 8f25692..0000000 --- a/0058-Handle-rssd-storage-devices.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 30 Jun 2015 15:50:41 -0400 -Subject: [PATCH] Handle rssd storage devices. - -Resolves: rhbz#1087962 - -Signed-off-by: Peter Jones ---- - grub-core/osdep/linux/getroot.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 90d92d3ad5c..6d9f4e5faa2 100644 ---- a/grub-core/osdep/linux/getroot.c -+++ b/grub-core/osdep/linux/getroot.c -@@ -921,6 +921,19 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, - return path; - } - -+ /* If this is an rssd device. */ -+ if ((strncmp ("rssd", p, 4) == 0) && p[4] >= 'a' && p[4] <= 'z') -+ { -+ char *pp = p + 4; -+ while (*pp >= 'a' && *pp <= 'z') -+ pp++; -+ if (*pp) -+ *is_part = 1; -+ /* /dev/rssd[a-z]+[0-9]* */ -+ *pp = '\0'; -+ return path; -+ } -+ - /* If this is a loop device */ - if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9') - { diff --git a/0078-grub2-btrfs-05-grub2-mkconfig.patch b/0058-grub2-btrfs-05-grub2-mkconfig.patch similarity index 95% rename from 0078-grub2-btrfs-05-grub2-mkconfig.patch rename to 0058-grub2-btrfs-05-grub2-mkconfig.patch index 2320e89..4cdf47b 100644 --- a/0078-grub2-btrfs-05-grub2-mkconfig.patch +++ b/0058-grub2-btrfs-05-grub2-mkconfig.patch @@ -13,10 +13,10 @@ Signed-off-by: Michael Chang 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 6247a0ba850..4649e92eb0f 100644 +index 60beaaa6962..e671ce68aec 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -258,7 +258,8 @@ export GRUB_DEFAULT \ +@@ -255,7 +255,8 @@ export GRUB_DEFAULT \ GRUB_BADRAM \ GRUB_OS_PROBER_SKIP_LIST \ GRUB_DISABLE_SUBMENU \ @@ -27,7 +27,7 @@ index 6247a0ba850..4649e92eb0f 100644 if test "x${grub_cfg}" != "x"; then rm -f "${grub_cfg}.new" diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 113a41f9409..b3aae534ddc 100644 +index 42c2ea9ba50..fafeac95061 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -52,7 +52,11 @@ grub_warn () @@ -90,7 +90,7 @@ index 858b526c925..de727e6ee6b 100644 +EOF +fi diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 55f4aa783cf..5cab299dc08 100644 +index 0f3c19e30cc..cbfaca34cc7 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -66,10 +66,14 @@ fi @@ -109,7 +109,7 @@ index 55f4aa783cf..5cab299dc08 100644 xzfs) rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index 47e0d3f5cd6..1519ec692fe 100644 +index ada20775a14..e9e73b815fb 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -73,10 +73,14 @@ fi diff --git a/0079-grub2-btrfs-06-subvol-mount.patch b/0059-grub2-btrfs-06-subvol-mount.patch similarity index 95% rename from 0079-grub2-btrfs-06-subvol-mount.patch rename to 0059-grub2-btrfs-06-subvol-mount.patch index 36824c8..5a92622 100644 --- a/0079-grub2-btrfs-06-subvol-mount.patch +++ b/0059-grub2-btrfs-06-subvol-mount.patch @@ -11,7 +11,7 @@ Subject: [PATCH] grub2-btrfs-06-subvol-mount 4 files changed, 392 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 2db89f71ea5..162723423ca 100644 +index 113c1f746c9..d323746ecfa 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -41,6 +41,7 @@ @@ -21,8 +21,8 @@ index 2db89f71ea5..162723423ca 100644 +#include #include #include - -@@ -263,6 +264,12 @@ static grub_err_t + #include +@@ -266,6 +267,12 @@ static grub_err_t grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, void *buf, grub_size_t size, int recursion_depth); @@ -35,7 +35,7 @@ index 2db89f71ea5..162723423ca 100644 static grub_err_t read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb) -@@ -1203,9 +1210,26 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) +@@ -1223,9 +1230,26 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) grub_err_t err; grub_uint64_t tree = 0; grub_uint8_t type; @@ -62,7 +62,7 @@ index 2db89f71ea5..162723423ca 100644 if (err) return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path); -@@ -2179,11 +2203,20 @@ grub_btrfs_dir (grub_device_t device, const char *path, +@@ -2199,11 +2223,20 @@ grub_btrfs_dir (grub_device_t device, const char *path, int r = 0; grub_uint64_t tree; grub_uint8_t type; @@ -84,7 +84,7 @@ index 2db89f71ea5..162723423ca 100644 if (err) { grub_btrfs_unmount (data); -@@ -2285,11 +2318,21 @@ grub_btrfs_open (struct grub_file *file, const char *name) +@@ -2305,11 +2338,21 @@ grub_btrfs_open (struct grub_file *file, const char *name) struct grub_btrfs_inode inode; grub_uint8_t type; struct grub_btrfs_key key_in; @@ -107,7 +107,7 @@ index 2db89f71ea5..162723423ca 100644 if (err) { grub_btrfs_unmount (data); -@@ -2460,6 +2503,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc, +@@ -2480,6 +2523,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc, return 0; } @@ -258,7 +258,7 @@ index 2db89f71ea5..162723423ca 100644 static grub_err_t get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree, grub_uint64_t objectid, grub_uint64_t offset, -@@ -2666,6 +2853,7 @@ static struct grub_fs grub_btrfs_fs = { +@@ -2686,6 +2873,7 @@ static struct grub_fs grub_btrfs_fs = { }; static grub_command_t cmd_info; @@ -266,7 +266,7 @@ index 2db89f71ea5..162723423ca 100644 static grub_extcmd_t cmd_list_subvols; static char * -@@ -2729,6 +2917,9 @@ GRUB_MOD_INIT (btrfs) +@@ -2749,6 +2937,9 @@ GRUB_MOD_INIT (btrfs) cmd_info = grub_register_command("btrfs-info", grub_cmd_btrfs_info, "DEVICE", "Print BtrFS info about DEVICE."); @@ -277,7 +277,7 @@ index 2db89f71ea5..162723423ca 100644 grub_cmd_btrfs_list_subvols, 0, "[-p|-n] [-o var] DEVICE", diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 5d50dd6f8dc..4c5a13022dc 100644 +index caf9b1ccd3f..28790307e00 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -107,6 +107,14 @@ struct btrfs_ioctl_search_key @@ -460,10 +460,10 @@ index 5d50dd6f8dc..4c5a13022dc 100644 grub_make_system_path_relative_to_its_root_os (const char *path) { diff --git a/util/grub-install.c b/util/grub-install.c -index 0e807b09c36..3e718b9e3fb 100644 +index 427ae013701..c03214bdfcf 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -1561,6 +1561,55 @@ main (int argc, char *argv[]) +@@ -1569,6 +1569,55 @@ main (int argc, char *argv[]) prefix_drive = xasprintf ("(%s)", grub_drives[0]); } diff --git a/0080-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch b/0060-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch similarity index 94% rename from 0080-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch rename to 0060-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch index f023ca2..b02ab53 100644 --- a/0080-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch +++ b/0060-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch @@ -10,10 +10,10 @@ Ref: bsc#953538 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 162723423ca..69c30e62354 100644 +index d323746ecfa..673ded03522 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -1240,11 +1240,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) +@@ -1260,11 +1260,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) return GRUB_ERR_NONE; } diff --git a/0081-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch b/0061-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch similarity index 97% rename from 0081-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch rename to 0061-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch index f88b891..d4e20cd 100644 --- a/0081-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch +++ b/0061-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch @@ -8,10 +8,10 @@ Subject: [PATCH] Grub not working correctly with btrfs snapshots (bsc#1026511) 1 file changed, 238 insertions(+) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 69c30e62354..ba99d04f8ed 100644 +index 673ded03522..2b21cbaa67e 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -2867,6 +2867,238 @@ out: +@@ -2887,6 +2887,238 @@ out: return 0; } @@ -250,7 +250,7 @@ index 69c30e62354..ba99d04f8ed 100644 static struct grub_fs grub_btrfs_fs = { .name = "btrfs", .fs_dir = grub_btrfs_dir, -@@ -2885,6 +3117,7 @@ static struct grub_fs grub_btrfs_fs = { +@@ -2905,6 +3137,7 @@ static struct grub_fs grub_btrfs_fs = { static grub_command_t cmd_info; static grub_command_t cmd_mount_subvol; static grub_extcmd_t cmd_list_subvols; @@ -258,7 +258,7 @@ index 69c30e62354..ba99d04f8ed 100644 static char * subvolid_set_env (struct grub_env_var *var __attribute__ ((unused)), -@@ -2955,6 +3188,11 @@ GRUB_MOD_INIT (btrfs) +@@ -2975,6 +3208,11 @@ GRUB_MOD_INIT (btrfs) "[-p|-n] [-o var] DEVICE", "Print list of BtrFS subvolumes on " "DEVICE.", options); diff --git a/0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch b/0062-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch similarity index 96% rename from 0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch rename to 0062-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch index ccb1947..bde7096 100644 --- a/0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch +++ b/0062-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 090c8621066..5e2b479daec 100644 +index 585fa6662b6..03f9a9d0118 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -24,6 +24,10 @@ @@ -58,7 +58,7 @@ index 090c8621066..5e2b479daec 100644 grub_efi_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle); void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp); char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp); -@@ -109,10 +140,7 @@ void grub_efi_init (void); +@@ -115,10 +146,7 @@ void grub_efi_init (void); void grub_efi_fini (void); void grub_efi_set_prefix (void); diff --git a/0062-Fix-security-issue-when-reading-username-and-passwor.patch b/0062-Fix-security-issue-when-reading-username-and-passwor.patch deleted file mode 100644 index 11bc434..0000000 --- a/0062-Fix-security-issue-when-reading-username-and-passwor.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hector Marco-Gisbert -Date: Fri, 13 Nov 2015 16:21:09 +0100 -Subject: [PATCH] Fix security issue when reading username and password - - This patch fixes two integer underflows at: - * grub-core/lib/crypto.c - * grub-core/normal/auth.c - -Resolves: CVE-2015-8370 - -Signed-off-by: Hector Marco-Gisbert -Signed-off-by: Ismael Ripoll-Ripoll ---- - grub-core/lib/crypto.c | 2 +- - grub-core/normal/auth.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c -index ca334d5a40e..e6c78d16d39 100644 ---- a/grub-core/lib/crypto.c -+++ b/grub-core/lib/crypto.c -@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size) - break; - } - -- if (key == '\b') -+ if (key == '\b' && cur_len) - { - if (cur_len) - cur_len--; -diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c -index 6be678c0de1..c35ce972473 100644 ---- a/grub-core/normal/auth.c -+++ b/grub-core/normal/auth.c -@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size) - break; - } - -- if (key == GRUB_TERM_BACKSPACE) -+ if (key == GRUB_TERM_BACKSPACE && cur_len) - { - if (cur_len) - { diff --git a/0063-Add-a-url-parser.patch b/0063-Add-a-url-parser.patch deleted file mode 100644 index d6047fb..0000000 --- a/0063-Add-a-url-parser.patch +++ /dev/null @@ -1,1021 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 14 Jun 2016 16:18:44 -0400 -Subject: [PATCH] Add a url parser. - -This patch adds a url parser that can parse http, https, tftp, and tftps -urls, and is easily extensible to handle more types. - -It's a little ugly in terms of the arguments it takes. - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 1 + - grub-core/kern/misc.c | 13 + - grub-core/net/url.c | 861 ++++++++++++++++++++++++++++++++++++++++++++ - include/grub/misc.h | 45 +++ - include/grub/net/url.h | 28 ++ - 5 files changed, 948 insertions(+) - create mode 100644 grub-core/net/url.c - create mode 100644 include/grub/net/url.h - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 57e253ab1a1..99466b1e47e 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -2284,6 +2284,7 @@ module = { - common = net/ethernet.c; - common = net/arp.c; - common = net/netbuff.c; -+ common = net/url.c; - }; - - module = { -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 2656a670e09..1c560ea570a 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -296,6 +296,19 @@ grub_strrchr (const char *s, int c) - return p; - } - -+char * -+grub_strchrnul (const char *s, int c) -+{ -+ do -+ { -+ if (*s == c) -+ break; -+ } -+ while (*s++); -+ -+ return (char *) s; -+} -+ - int - grub_strword (const char *haystack, const char *needle) - { -diff --git a/grub-core/net/url.c b/grub-core/net/url.c -new file mode 100644 -index 00000000000..146858284cd ---- /dev/null -+++ b/grub-core/net/url.c -@@ -0,0 +1,861 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifdef URL_TEST -+ -+#define _GNU_SOURCE 1 -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define N_(x) x -+ -+#define grub_malloc(x) malloc(x) -+#define grub_free(x) ({if (x) free(x);}) -+#define grub_error(a, fmt, args...) printf(fmt "\n", ## args) -+#define grub_dprintf(a, fmt, args...) printf(a ": " fmt, ## args) -+#define grub_strlen(x) strlen(x) -+#define grub_strdup(x) strdup(x) -+#define grub_strstr(x,y) strstr(x,y) -+#define grub_memcpy(x,y,z) memcpy(x,y,z) -+#define grub_strcmp(x,y) strcmp(x,y) -+#define grub_strncmp(x,y,z) strncmp(x,y,z) -+#define grub_strcasecmp(x,y) strcasecmp(x,y) -+#define grub_strchrnul(x,y) strchrnul(x,y) -+#define grub_strchr(x,y) strchr(x,y) -+#define grub_strndup(x,y) strndup(x,y) -+#define grub_strtoul(x,y,z) strtoul(x,y,z) -+#define grub_memmove(x,y,z) memmove(x,y,z) -+#define grub_size_t size_t -+#define grub_errno errno -+ -+#else -+#include -+#include -+#include -+#include -+#endif -+ -+static char * -+translate_slashes(char *str) -+{ -+ int i, j; -+ if (str == NULL) -+ return str; -+ -+ for (i = 0, j = 0; str[i] != '\0'; i++, j++) -+ { -+ if (str[i] == '\\') -+ { -+ str[j] = '/'; -+ if (str[i+1] == '\\') -+ i++; -+ } -+ } -+ -+ return str; -+} -+ -+static inline int -+hex2int (char c) -+{ -+ if (c >= '0' && c <= '9') -+ return c - '0'; -+ c |= 0x20; -+ if (c >= 'a' && c <= 'f') -+ return c - 'a' + 10; -+ return -1; -+} -+ -+static int -+url_unescape (char *buf, grub_size_t len) -+{ -+ int c, rc; -+ unsigned int i; -+ -+ -+ if (len < 3) -+ { -+ for (i = 0; i < len; i++) -+ if (buf[i] == '%') -+ return -1; -+ return 0; -+ } -+ -+ for (i = 0; len > 2 && i < len - 2; i++) -+ { -+ if (buf[i] == '%') -+ { -+ unsigned int j; -+ for (j = i+1; j < i+3; j++) -+ { -+ if (!(buf[j] >= '0' && buf[j] <= '9') && -+ !(buf[j] >= 'a' && buf[j] <= 'f') && -+ !(buf[j] >= 'A' && buf[j] <= 'F')) -+ return -1; -+ } -+ i += 2; -+ } -+ } -+ if (i == len - 2) -+ { -+ if (buf[i+1] == '%' || buf[i+2] == '%') -+ return -1; -+ } -+ for (i = 0; i < len - 2; i++) -+ { -+ if (buf[i] == '%') -+ { -+ rc = hex2int (buf[i+1]); -+ if (rc < 0) -+ return -1; -+ c = (rc & 0xf) << 4; -+ rc = hex2int (buf[i+2]); -+ if (rc < 0) -+ return -1; -+ c |= (rc & 0xf); -+ -+ buf[i] = c; -+ grub_memmove (buf+i+1, buf+i+3, len-(i+2)); -+ len -= 2; -+ } -+ } -+ return 0; -+} -+ -+static int -+extract_http_url_info (char *url, int ssl, -+ char **userinfo, char **host, int *port, -+ char **file) -+{ -+ char *colon, *slash, *query, *at = NULL, *separator, *auth_end; -+ -+ char *userinfo_off = NULL; -+ char *userinfo_end; -+ char *host_off = NULL; -+ char *host_end; -+ char *port_off = NULL; -+ char *port_end; -+ char *file_off = NULL; -+ -+ grub_size_t l; -+ int c; -+ -+ if (!url || !userinfo || !host || !port || !file) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument"); -+ -+ *userinfo = *host = *file = NULL; -+ *port = -1; -+ -+ userinfo_off = url; -+ -+ slash = grub_strchrnul (userinfo_off, '/'); -+ query = grub_strchrnul (userinfo_off, '?'); -+ auth_end = slash < query ? slash : query; -+ /* auth_end here is one /past/ the last character in the auth section, i.e. -+ * it's the : or / or NUL */ -+ -+ separator = grub_strchrnul (userinfo_off, '@'); -+ if (separator > auth_end) -+ { -+ host_off = userinfo_off; -+ userinfo_off = NULL; -+ userinfo_end = NULL; -+ } -+ else -+ { -+ at = separator; -+ *separator = '\0'; -+ userinfo_end = separator; -+ host_off = separator + 1; -+ } -+ -+ if (*host_off == '[') -+ { -+ separator = grub_strchrnul (host_off, ']'); -+ if (separator >= auth_end) -+ goto fail; -+ -+ separator += 1; -+ host_end = separator; -+ } -+ else -+ { -+ host_end = separator = colon = grub_strchrnul (host_off, ':'); -+ -+ if (colon > auth_end) -+ { -+ separator = NULL; -+ host_end = auth_end; -+ } -+ } -+ -+ if (separator && separator < auth_end) -+ { -+ if (*separator == ':') -+ { -+ port_off = separator + 1; -+ port_end = auth_end; -+ -+ if (auth_end - port_end > 0) -+ goto fail; -+ if (port_end - port_off < 1) -+ goto fail; -+ } -+ else -+ goto fail; -+ } -+ -+ file_off = auth_end; -+ if (port_off) -+ { -+ unsigned long portul; -+ -+ separator = NULL; -+ c = *port_end; -+ *port_end = '\0'; -+ -+ portul = grub_strtoul (port_off, &separator, 10); -+ *port_end = c; -+#ifdef URL_TEST -+ if (portul == ULONG_MAX && errno == ERANGE) -+ goto fail; -+#else -+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE) -+ goto fail; -+#endif -+ if (portul & ~0xfffful) -+ goto fail; -+ if (separator != port_end) -+ goto fail; -+ -+ *port = portul & 0xfffful; -+ } -+ else if (ssl) -+ *port = 443; -+ else -+ *port = 80; -+ -+ if (userinfo_off && *userinfo_off) -+ { -+ l = userinfo_end - userinfo_off + 1; -+ -+ *userinfo = grub_strndup (userinfo_off, l); -+ if (!*userinfo) -+ goto fail; -+ (*userinfo)[l-1]= '\0'; -+ } -+ -+ l = host_end - host_off; -+ -+ if (host_end == NULL) -+ goto fail; -+ else -+ c = *host_end; -+ -+ *host_end = '\0'; -+ *host = grub_strndup (host_off, l); -+ *host_end = c; -+ if (!*host) -+ goto fail; -+ (*host)[l] = '\0'; -+ -+ *file = grub_strdup (file_off); -+ if (!*file) -+ goto fail; -+ -+ if (at) -+ *at = '@'; -+ return 0; -+fail: -+ if (at) -+ *at = '@'; -+ grub_free (*userinfo); -+ grub_free (*host); -+ grub_free (*file); -+ -+ return -1; -+} -+ -+static int -+extract_tftp_url_info (char *url, int ssl, char **host, char **file, int *port) -+{ -+ char *slash, *semi; -+ -+ char *host_off = url; -+ char *host_end; -+ char *file_off; -+ -+ int c; -+ -+ if (!url || !host || !file || !port) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument"); -+ -+ if (ssl) -+ *port = 3713; -+ else -+ *port = 69; -+ -+ slash = grub_strchr (url, '/'); -+ if (!slash) -+ return -1; -+ -+ host_end = file_off = slash; -+ -+ semi = grub_strchrnul (slash, ';'); -+ if (!grub_strncmp (semi, ";mode=", 6) && grub_strcmp (semi+6, "octet")) -+ { -+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ N_("TFTP mode `%s' is not implemented."), semi+6); -+ return -1; -+ } -+ -+ /* -+ * Maybe somebody added a new method, I dunno. Anyway, semi is a reserved -+ * character, so if it's there, it's the start of the mode block or it's -+ * invalid. So set it to \0 unconditionally, not just for ;mode=octet -+ */ -+ *semi = '\0'; -+ -+ c = *host_end; -+ *host_end = '\0'; -+ *host = grub_strdup (host_off); -+ *host_end = c; -+ -+ *file = grub_strdup (file_off); -+ -+ if (!*file || !*host) -+ { -+ grub_free (*file); -+ grub_free (*host); -+ return -1; -+ } -+ -+ return 0; -+} -+ -+int -+extract_url_info (const char *urlbuf, grub_size_t buflen, -+ char **scheme, char **userinfo, -+ char **host, int *port, char **file) -+{ -+ char *url; -+ char *colon; -+ -+ char *scheme_off; -+ char *specific_off; -+ -+ int rc; -+ int c; -+ -+ int https; -+ -+ if (!urlbuf || !buflen || !scheme || !userinfo || !host || !port || !file) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument"); -+ -+ *scheme = *userinfo = *host = *file = NULL; -+ *port = -1; -+ -+ /* make sure we have our own coherent grub_string. */ -+ url = grub_malloc (buflen + 1); -+ if (!url) -+ return -1; -+ -+ grub_memcpy (url, urlbuf, buflen); -+ url[buflen] = '\0'; -+ -+ grub_dprintf ("net", "dhcpv6 boot-file-url: `%s'\n", url); -+ -+ /* get rid of any backslashes */ -+ url = translate_slashes (url); -+ -+ /* find the constituent parts */ -+ colon = grub_strstr (url, "://"); -+ if (!colon) -+ goto fail; -+ -+ scheme_off = url; -+ c = *colon; -+ *colon = '\0'; -+ specific_off = colon + 3; -+ -+ https = !grub_strcasecmp (scheme_off, "https"); -+ -+ rc = 0; -+ if (!grub_strcasecmp (scheme_off, "tftp")) -+ { -+ rc = extract_tftp_url_info (specific_off, 0, host, file, port); -+ } -+#ifdef URL_TEST -+ else if (!grub_strcasecmp (scheme_off, "http") || https) -+#else -+ else if (!grub_strcasecmp (scheme_off, "http")) -+#endif -+ { -+ rc = extract_http_url_info (specific_off, -+ https, userinfo, host, port, file); -+ } -+#ifdef URL_TEST -+ else if (!grub_strcasecmp (scheme_off, "iscsi")) -+ { -+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ N_("Unimplemented URL scheme `%s'"), scheme_off); -+ *colon = c; -+ goto fail; -+ } -+ else if (!grub_strcasecmp (scheme_off, "tftps")) -+ { -+ rc = extract_tftp_url_info (specific_off, 1, host, file, port); -+ } -+#endif -+ else -+ { -+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ N_("Unimplemented URL scheme `%s'"), scheme_off); -+ *colon = c; -+ goto fail; -+ } -+ -+ if (rc < 0) -+ { -+ *colon = c; -+ goto fail; -+ } -+ -+ *scheme = grub_strdup (scheme_off); -+ *colon = c; -+ if (!*scheme) -+ goto fail; -+ -+ if (*userinfo) -+ { -+ rc = url_unescape (*userinfo, grub_strlen (*userinfo)); -+ if (rc < 0) -+ goto fail; -+ } -+ -+ if (*host) -+ { -+ rc = url_unescape (*host, grub_strlen (*host)); -+ if (rc < 0) -+ goto fail; -+ } -+ -+ if (*file) -+ { -+ rc = url_unescape (*file, grub_strlen (*file)); -+ if (rc < 0) -+ goto fail; -+ } -+ -+ grub_free (url); -+ return 0; -+fail: -+ grub_free (*scheme); -+ grub_free (*userinfo); -+ grub_free (*host); -+ grub_free (*file); -+ -+ if (!grub_errno) -+ grub_error (GRUB_ERR_NET_BAD_ADDRESS, N_("Invalid boot-file-url `%s'"), -+ url); -+ grub_free (url); -+ return -1; -+} -+ -+#ifdef URL_TEST -+ -+struct test { -+ char *url; -+ int rc; -+ char *scheme; -+ char *userinfo; -+ char *host; -+ int port; -+ char *file; -+} tests[] = { -+ {.url = "http://foo.example.com/", -+ .rc = 0, -+ .scheme = "http", -+ .host = "foo.example.com", -+ .port = 80, -+ .file = "/", -+ }, -+ {.url = "http://foo.example.com/?foobar", -+ .rc = 0, -+ .scheme = "http", -+ .host = "foo.example.com", -+ .port = 80, -+ .file = "/?foobar", -+ }, -+ {.url = "http://[foo.example.com/", -+ .rc = -1, -+ }, -+ {.url = "http://[foo.example.com/?foobar", -+ .rc = -1, -+ }, -+ {.url = "http://foo.example.com:/", -+ .rc = -1, -+ }, -+ {.url = "http://foo.example.com:81/", -+ .rc = 0, -+ .scheme = "http", -+ .host = "foo.example.com", -+ .port = 81, -+ .file = "/", -+ }, -+ {.url = "http://foo.example.com:81/?foobar", -+ .rc = 0, -+ .scheme = "http", -+ .host = "foo.example.com", -+ .port = 81, -+ .file = "/?foobar", -+ }, -+ {.url = "http://[1234::1]/", -+ .rc = 0, -+ .scheme = "http", -+ .host = "[1234::1]", -+ .port = 80, -+ .file = "/", -+ }, -+ {.url = "http://[1234::1]/?foobar", -+ .rc = 0, -+ .scheme = "http", -+ .host = "[1234::1]", -+ .port = 80, -+ .file = "/?foobar", -+ }, -+ {.url = "http://[1234::1]:81/", -+ .rc = 0, -+ .scheme = "http", -+ .host = "[1234::1]", -+ .port = 81, -+ .file = "/", -+ }, -+ {.url = "http://[1234::1]:81/?foobar", -+ .rc = 0, -+ .scheme = "http", -+ .host = "[1234::1]", -+ .port = 81, -+ .file = "/?foobar", -+ }, -+ {.url = "http://foo@foo.example.com/", -+ .rc = 0, -+ .scheme = "http", -+ .userinfo = "foo", -+ .host = "foo.example.com", -+ .port = 80, -+ .file = "/", -+ }, -+ {.url = "http://foo@foo.example.com/?foobar", -+ .rc = 0, -+ .scheme = "http", -+ .userinfo = "foo", -+ .host = "foo.example.com", -+ .port = 80, -+ .file = "/?foobar", -+ }, -+ {.url = "http://foo@[foo.example.com/", -+ .rc = -1, -+ }, -+ {.url = "http://foo@[foo.example.com/?foobar", -+ .rc = -1, -+ }, -+ {.url = "http://foo@foo.example.com:81/", -+ .rc = 0, -+ .scheme = "http", -+ .userinfo = "foo", -+ .host = "foo.example.com", -+ .port = 81, -+ .file = "/", -+ }, -+ {.url = "http://foo@foo.example.com:81/?foobar", -+ .rc = 0, -+ .scheme = "http", -+ .userinfo = "foo", -+ .host = "foo.example.com", -+ .port = 81, -+ .file = "/?foobar", -+ }, -+ {.url = "http://foo@[1234::1]/", -+ .rc = 0, -+ .scheme = "http", -+ .userinfo = "foo", -+ .host = "[1234::1]", -+ .port = 80, -+ .file = "/", -+ }, -+ {.url = "http://foo@[1234::1]/?foobar", -+ .rc = 0, -+ .scheme = "http", -+ .userinfo = "foo", -+ .host = "[1234::1]", -+ .port = 80, -+ .file = "/?foobar", -+ }, -+ {.url = "http://foo@[1234::1]:81/", -+ .rc = 0, -+ .scheme = "http", -+ .userinfo = "foo", -+ .host = "[1234::1]", -+ .port = 81, -+ .file = "/", -+ }, -+ {.url = "http://foo@[1234::1]:81/?foobar", -+ .rc = 0, -+ .scheme = "http", -+ .userinfo = "foo", -+ .host = "[1234::1]", -+ .port = 81, -+ .file = "/?foobar", -+ }, -+ {.url = "https://foo.example.com/", -+ .rc = 0, -+ .scheme = "https", -+ .host = "foo.example.com", -+ .port = 443, -+ .file = "/", -+ }, -+ {.url = "https://foo.example.com/?foobar", -+ .rc = 0, -+ .scheme = "https", -+ .host = "foo.example.com", -+ .port = 443, -+ .file = "/?foobar", -+ }, -+ {.url = "https://[foo.example.com/", -+ .rc = -1, -+ }, -+ {.url = "https://[foo.example.com/?foobar", -+ .rc = -1, -+ }, -+ {.url = "https://foo.example.com:81/", -+ .rc = 0, -+ .scheme = "https", -+ .host = "foo.example.com", -+ .port = 81, -+ .file = "/", -+ }, -+ {.url = "https://foo.example.com:81/?foobar", -+ .rc = 0, -+ .scheme = "https", -+ .host = "foo.example.com", -+ .port = 81, -+ .file = "/?foobar", -+ }, -+ {.url = "https://[1234::1]/", -+ .rc = 0, -+ .scheme = "https", -+ .host = "[1234::1]", -+ .port = 443, -+ .file = "/", -+ }, -+ {.url = "https://[1234::1]/?foobar", -+ .rc = 0, -+ .scheme = "https", -+ .host = "[1234::1]", -+ .port = 443, -+ .file = "/?foobar", -+ }, -+ {.url = "https://[1234::1]:81/", -+ .rc = 0, -+ .scheme = "https", -+ .host = "[1234::1]", -+ .port = 81, -+ .file = "/", -+ }, -+ {.url = "https://[1234::1]:81/?foobar", -+ .rc = 0, -+ .scheme = "https", -+ .host = "[1234::1]", -+ .port = 81, -+ .file = "/?foobar", -+ }, -+ {.url = "https://foo@foo.example.com/", -+ .rc = 0, -+ .scheme = "https", -+ .userinfo = "foo", -+ .host = "foo.example.com", -+ .port = 443, -+ .file = "/", -+ }, -+ {.url = "https://foo@foo.example.com/?foobar", -+ .rc = 0, -+ .scheme = "https", -+ .userinfo = "foo", -+ .host = "foo.example.com", -+ .port = 443, -+ .file = "/?foobar", -+ }, -+ {.url = "https://foo@[foo.example.com/", -+ .rc = -1, -+ }, -+ {.url = "https://f%6fo@[foo.example.com/?fooba%72", -+ .rc = -1, -+ }, -+ {.url = "https://foo@foo.example.com:81/", -+ .rc = 0, -+ .scheme = "https", -+ .userinfo = "foo", -+ .host = "foo.example.com", -+ .port = 81, -+ .file = "/", -+ }, -+ {.url = "https://foo@foo.example.com:81/?foobar", -+ .rc = 0, -+ .scheme = "https", -+ .userinfo = "foo", -+ .host = "foo.example.com", -+ .port = 81, -+ .file = "/?foobar", -+ }, -+ {.url = "https://foo@[1234::1]/", -+ .rc = 0, -+ .scheme = "https", -+ .userinfo = "foo", -+ .host = "[1234::1]", -+ .port = 443, -+ .file = "/", -+ }, -+ {.url = "https://foo@[1234::1]/?foobar", -+ .rc = 0, -+ .scheme = "https", -+ .userinfo = "foo", -+ .host = "[1234::1]", -+ .port = 443, -+ .file = "/?foobar", -+ }, -+ {.url = "https://f%6fo@[12%334::1]:81/", -+ .rc = 0, -+ .scheme = "https", -+ .userinfo = "foo", -+ .host = "[1234::1]", -+ .port = 81, -+ .file = "/", -+ }, -+ {.url = "https://foo@[1234::1]:81/?foobar", -+ .rc = 0, -+ .scheme = "https", -+ .userinfo = "foo", -+ .host = "[1234::1]", -+ .port = 81, -+ .file = "/?foobar", -+ }, -+ {.url = "tftp://foo.e%78ample.com/foo/bar/b%61%7a", -+ .rc = 0, -+ .scheme = "tftp", -+ .host = "foo.example.com", -+ .port = 69, -+ .file = "/foo/bar/baz", -+ }, -+ {.url = "tftp://foo.example.com/foo/bar/baz", -+ .rc = 0, -+ .scheme = "tftp", -+ .host = "foo.example.com", -+ .port = 69, -+ .file = "/foo/bar/baz", -+ }, -+ {.url = "tftps://foo.example.com/foo/bar/baz", -+ .rc = 0, -+ .scheme = "tftps", -+ .host = "foo.example.com", -+ .port = 3713, -+ .file = "/foo/bar/baz", -+ }, -+ {.url = "tftps://foo.example.com/foo/bar/baz;mode=netascii", -+ .rc = -1, -+ }, -+ {.url = "tftps://foo.example.com/foo/bar/baz;mode=octet", -+ .rc = 0, -+ .scheme = "tftps", -+ .host = "foo.example.com", -+ .port = 3713, -+ .file = "/foo/bar/baz", -+ }, -+ {.url = "tftps://foo.example.com/foo/bar/baz;mode=invalid", -+ .rc = -1, -+ }, -+ {.url = "", -+ }, -+}; -+ -+static int -+string_test (char *name, char *a, char *b) -+{ -+ if ((a && !b) || (!a && b)) -+ { -+ printf("expected %s \"%s\", got \"%s\"\n", name, a, b); -+ return -1; -+ } -+ if (a && b && strcmp(a, b)) -+ { -+ printf("expected %s \"%s\", got \"%s\"\n", name, a, b); -+ return -1; -+ } -+ return 0; -+} -+ -+int -+main(void) -+{ -+ unsigned int i; -+ int rc; -+ -+ for (i = 0; tests[i].url[0] != '\0'; i++) -+ { -+ char *scheme, *userinfo, *host, *file; -+ int port; -+ -+ printf("======= url: \"%s\"\n", tests[i].url); -+ rc = extract_url_info(tests[i].url, strlen(tests[i].url) + 1, -+ &scheme, &userinfo, &host, &port, &file); -+ if (tests[i].rc != rc) -+ { -+ printf(" extract_url_info(...) = %d\n", rc); -+ exit(1); -+ } -+ else if (rc >= 0) -+ { -+ if (string_test("scheme", tests[i].scheme, scheme) < 0) -+ exit(1); -+ if (string_test("userinfo", tests[i].userinfo, userinfo) < 0) -+ exit(1); -+ if (string_test("host", tests[i].host, host) < 0) -+ exit(1); -+ if (port != tests[i].port) -+ { -+ printf(" bad port \"%d\" should have been \"%d\"\n", -+ port, tests[i].port); -+ exit(1); -+ } -+ if (string_test("file", tests[i].file, file) < 0) -+ exit(1); -+ } -+ free(scheme); -+ free(userinfo); -+ free(host); -+ free(file); -+ } -+ printf("everything worked?!?\n"); -+} -+#endif -diff --git a/include/grub/misc.h b/include/grub/misc.h -index f9135b62e35..b4339222ecb 100644 ---- a/include/grub/misc.h -+++ b/include/grub/misc.h -@@ -85,6 +85,7 @@ int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n); - - char *EXPORT_FUNC(grub_strchr) (const char *s, int c); - char *EXPORT_FUNC(grub_strrchr) (const char *s, int c); -+char *EXPORT_FUNC(grub_strchrnul) (const char *s, int c); - int EXPORT_FUNC(grub_strword) (const char *s, const char *w); - - /* Copied from gnulib. -@@ -207,6 +208,50 @@ grub_toupper (int c) - return c; - } - -+static inline char * -+grub_strcasestr (const char *haystack, const char *needle) -+{ -+ /* Be careful not to look at the entire extent of haystack or needle -+ until needed. This is useful because of these two cases: -+ - haystack may be very long, and a match of needle found early, -+ - needle may be very long, and not even a short initial segment of -+ needle may be found in haystack. */ -+ if (*needle != '\0') -+ { -+ /* Speed up the following searches of needle by caching its first -+ character. */ -+ char b = *needle++; -+ -+ for (;; haystack++) -+ { -+ if (*haystack == '\0') -+ /* No match. */ -+ return 0; -+ if (grub_tolower(*haystack) == grub_tolower(b)) -+ /* The first character matches. */ -+ { -+ const char *rhaystack = haystack + 1; -+ const char *rneedle = needle; -+ -+ for (;; rhaystack++, rneedle++) -+ { -+ if (*rneedle == '\0') -+ /* Found a match. */ -+ return (char *) haystack; -+ if (*rhaystack == '\0') -+ /* No match. */ -+ return 0; -+ if (grub_tolower(*rhaystack) != grub_tolower(*rneedle)) -+ /* Nothing in this round. */ -+ break; -+ } -+ } -+ } -+ } -+ else -+ return (char *) haystack; -+} -+ - static inline int - grub_strcasecmp (const char *s1, const char *s2) - { -diff --git a/include/grub/net/url.h b/include/grub/net/url.h -new file mode 100644 -index 00000000000..a215fa27d0a ---- /dev/null -+++ b/include/grub/net/url.h -@@ -0,0 +1,28 @@ -+/* url.h - prototypes for url parsing functions */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_URL_HEADER -+#define GRUB_URL_HEADER 1 -+ -+int -+EXPORT_FUNC(extract_url_info) (const char *urlbuf, grub_size_t buflen, -+ char **scheme, char **userinfo, -+ char **host, int *port, char **file); -+ -+#endif /* GRUB_URL_HEADER */ diff --git a/0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch b/0063-Use-grub_efi_.-memory-helpers-where-reasonable.patch similarity index 89% rename from 0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch rename to 0063-Use-grub_efi_.-memory-helpers-where-reasonable.patch index a9e1a2b..4fa92c0 100644 --- a/0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch +++ b/0063-Use-grub_efi_.-memory-helpers-where-reasonable.patch @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 5aa3a5dc7dd..3a724a9fcbf 100644 +index 3ff305b1d32..ba3d2930197 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -65,7 +65,7 @@ grub_chainloader_unload (void) @@ -34,7 +34,7 @@ index 5aa3a5dc7dd..3a724a9fcbf 100644 grub_loader_unset (); -@@ -506,10 +506,9 @@ grub_efi_get_media_file_path (grub_efi_device_path_t *dp) +@@ -523,10 +523,9 @@ grub_efi_get_media_file_path (grub_efi_device_path_t *dp) static grub_efi_boolean_t handle_image (void *data, grub_efi_uint32_t datasize) { @@ -46,7 +46,7 @@ index 5aa3a5dc7dd..3a724a9fcbf 100644 char *buffer_aligned = NULL; grub_efi_uint32_t i; struct grub_pe32_section_table *section; -@@ -520,8 +519,6 @@ handle_image (void *data, grub_efi_uint32_t datasize) +@@ -537,8 +536,6 @@ handle_image (void *data, grub_efi_uint32_t datasize) int found_entry_point = 0; int rc; @@ -55,7 +55,7 @@ index 5aa3a5dc7dd..3a724a9fcbf 100644 rc = read_header (data, datasize, &context); if (rc < 0) { -@@ -561,8 +558,8 @@ handle_image (void *data, grub_efi_uint32_t datasize) +@@ -578,8 +575,8 @@ handle_image (void *data, grub_efi_uint32_t datasize) grub_dprintf ("chain", "image size is %08"PRIxGRUB_UINT64_T", datasize is %08x\n", context.image_size, datasize); @@ -66,7 +66,7 @@ index 5aa3a5dc7dd..3a724a9fcbf 100644 if (efi_status != GRUB_EFI_SUCCESS) { -@@ -794,14 +791,14 @@ handle_image (void *data, grub_efi_uint32_t datasize) +@@ -811,14 +808,14 @@ handle_image (void *data, grub_efi_uint32_t datasize) grub_dprintf ("chain", "entry_point returned %ld\n", efi_status); grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t)); @@ -83,7 +83,7 @@ index 5aa3a5dc7dd..3a724a9fcbf 100644 return 0; } -@@ -809,10 +806,7 @@ error_exit: +@@ -826,10 +823,7 @@ error_exit: static grub_err_t grub_secureboot_chainloader_unload (void) { @@ -95,7 +95,7 @@ index 5aa3a5dc7dd..3a724a9fcbf 100644 grub_free (file_path); grub_free (cmdline); cmdline = 0; -@@ -1079,7 +1073,7 @@ fail: +@@ -1096,7 +1090,7 @@ fail: grub_free (file_path); if (address) diff --git a/0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch b/0064-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch similarity index 78% rename from 0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch rename to 0064-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch index d438465..1a96b43 100644 --- a/0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch +++ b/0064-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch @@ -8,14 +8,14 @@ This avoids syntax checkers getting confused about if it's llx or lx. Signed-off-by: Peter Jones --- grub-core/loader/efi/chainloader.c | 3 ++- - include/grub/efi/api.h | 8 ++++++++ - 2 files changed, 10 insertions(+), 1 deletion(-) + include/grub/efi/api.h | 9 +++++++++ + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 3a724a9fcbf..f4ddbeda687 100644 +index ba3d2930197..47f5aa14817 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -789,7 +789,8 @@ handle_image (void *data, grub_efi_uint32_t datasize) +@@ -806,7 +806,8 @@ handle_image (void *data, grub_efi_uint32_t datasize) efi_status = efi_call_2 (entry_point, grub_efi_image_handle, grub_efi_system_table); @@ -26,13 +26,15 @@ index 3a724a9fcbf..f4ddbeda687 100644 efi_status = grub_efi_free_pool (buffer); diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index d97cdf98c80..955973ed484 100644 +index 117469450d3..99628801478 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -527,6 +527,14 @@ typedef grub_uint8_t grub_efi_char8_t; +@@ -546,7 +546,16 @@ typedef grub_uint64_t grub_efi_uint64_t; + typedef grub_uint8_t grub_efi_char8_t; typedef grub_uint16_t grub_efi_char16_t; - typedef grub_efi_intn_t grub_efi_status_t; ++ + typedef grub_efi_uintn_t grub_efi_status_t; +/* Make grub_efi_status_t reasonably printable. */ +#if GRUB_CPU_SIZEOF_VOID_P == 8 +#define PRIxGRUB_EFI_STATUS "lx" diff --git a/0087-don-t-use-int-for-efi-status.patch b/0065-don-t-use-int-for-efi-status.patch similarity index 88% rename from 0087-don-t-use-int-for-efi-status.patch rename to 0065-don-t-use-int-for-efi-status.patch index 9cdf63e..44d3555 100644 --- a/0087-don-t-use-int-for-efi-status.patch +++ b/0065-don-t-use-int-for-efi-status.patch @@ -8,10 +8,10 @@ Subject: [PATCH] don't use int for efi status 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index a1af9b46559..2cf6a5ad526 100644 +index 05d8237a9b2..ae9885edb84 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -166,7 +166,7 @@ grub_reboot (void) +@@ -167,7 +167,7 @@ grub_reboot (void) void grub_exit (int retval) { diff --git a/0066-Normalize-slashes-in-tftp-paths.patch b/0066-Normalize-slashes-in-tftp-paths.patch deleted file mode 100644 index 57f5e5e..0000000 --- a/0066-Normalize-slashes-in-tftp-paths.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lenny Szubowicz -Date: Mon, 29 Aug 2016 11:04:48 -0400 -Subject: [PATCH] Normalize slashes in tftp paths. - -Some tftp servers do not handle multiple consecutive slashes correctly; -this patch avoids sending tftp requests with non-normalized paths. - -Signed-off-by: Lenny Szubowicz -[msalter: fix malformed tftp packets] -Signed-off-by: Mark Salter ---- - grub-core/net/tftp.c | 28 +++++++++++++++++++++++++--- - 1 file changed, 25 insertions(+), 3 deletions(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index a5c5038130a..e6d831f1bc9 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -300,6 +300,25 @@ destroy_pq (tftp_data_t data) - grub_priority_queue_destroy (data->pq); - } - -+/* Create a normalized copy of the filename. -+ Compress any string of consecutive forward slashes to a single forward -+ slash. */ -+static void -+grub_normalize_filename (char *normalized, const char *filename) -+{ -+ char *dest = normalized; -+ char *src = filename; -+ -+ while (*src != '\0') -+ { -+ if (src[0] == '/' && src[1] == '/') -+ src++; -+ else -+ *dest++ = *src++; -+ } -+ *dest = '\0'; -+} -+ - static grub_err_t - tftp_open (struct grub_file *file, const char *filename) - { -@@ -337,9 +356,12 @@ tftp_open (struct grub_file *file, const char *filename) - rrqlen = 0; - - tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ); -- grub_strcpy (rrq, filename); -- rrqlen += grub_strlen (filename) + 1; -- rrq += grub_strlen (filename) + 1; -+ -+ /* Copy and normalize the filename to work-around issues on some tftp -+ servers when file names are being matched for remapping. */ -+ grub_normalize_filename (rrq, filename); -+ rrqlen += grub_strlen (rrq) + 1; -+ rrq += grub_strlen (rrq) + 1; - - grub_strcpy (rrq, "octet"); - rrqlen += grub_strlen ("octet") + 1; diff --git a/0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch b/0066-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch similarity index 96% rename from 0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch rename to 0066-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch index 993034f..1014900 100644 --- a/0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch +++ b/0066-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch @@ -8,7 +8,7 @@ Subject: [PATCH] make GRUB_MOD_INIT() declare its function prototypes. 1 file changed, 2 insertions(+) diff --git a/include/grub/dl.h b/include/grub/dl.h -index f03c03561a1..90dc9bb1017 100644 +index b3753c9ca26..91933b85f2c 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -54,6 +54,7 @@ grub_mod_fini (void) diff --git a/0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch b/0067-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch similarity index 92% rename from 0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch rename to 0067-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch index 1e8743a..89a65db 100644 --- a/0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch +++ b/0067-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch @@ -16,10 +16,10 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/util/grub-install.c b/util/grub-install.c -index 3e718b9e3fb..37fcdac12cc 100644 +index c03214bdfcf..1e47491bc21 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -1182,18 +1182,8 @@ main (int argc, char *argv[]) +@@ -1190,18 +1190,8 @@ main (int argc, char *argv[]) char *d; is_guess = 1; diff --git a/0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch b/0068-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch similarity index 51% rename from 0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch rename to 0068-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch index b2c7519..aa4cc8a 100644 --- a/0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch +++ b/0068-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch @@ -5,43 +5,27 @@ Subject: [PATCH] 20_linux_xen: load xen or multiboot{,2} modules as needed. Signed-off-by: Peter Jones --- - util/grub.d/20_linux_xen.in | 5 +++++ - 1 file changed, 5 insertions(+) + util/grub.d/20_linux_xen.in | 3 +++ + 1 file changed, 3 insertions(+) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index 1519ec692fe..b6e4608db6e 100644 +index e9e73b815fb..f8897479fe6 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in -@@ -136,6 +136,7 @@ linux_entry () +@@ -153,6 +153,8 @@ linux_entry_xsm () else xen_rm_opts="no-real-mode edd=off" fi -+ insmod ${xen_module} ++ insmod ${module_loader} ++ insmod ${xen_loader} ${xen_loader} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} echo '$(echo "$lmessage" | grub_quote)' ${module_loader} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} -@@ -149,6 +150,7 @@ EOF +@@ -166,6 +168,7 @@ EOF done sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' -+ insmod ${xen_module} ++ insmod ${module_loader} ${module_loader} --nounzip $(echo $initrd_path) EOF fi -@@ -225,13 +227,16 @@ while [ "x${xen_list}" != "x" ] ; do - echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {" - fi - if ($grub_file --is-arm64-efi $current_xen); then -+ xen_module="xen_boot" - xen_loader="xen_hypervisor" - module_loader="xen_module" - else - if ($grub_file --is-x86-multiboot2 $current_xen); then -+ xen_module="multiboot2" - xen_loader="multiboot2" - module_loader="module2" - else -+ xen_module="multiboot" - xen_loader="multiboot" - module_loader="module" - fi diff --git a/0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch b/0069-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch similarity index 100% rename from 0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch rename to 0069-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch diff --git a/0094-align-struct-efi_variable-better.patch b/0070-align-struct-efi_variable-better.patch similarity index 96% rename from 0094-align-struct-efi_variable-better.patch rename to 0070-align-struct-efi_variable-better.patch index 0afd935..6d28e6d 100644 --- a/0094-align-struct-efi_variable-better.patch +++ b/0070-align-struct-efi_variable-better.patch @@ -20,7 +20,7 @@ index 36d2dedf47e..9d93ba88bac 100644 +} GRUB_PACKED GRUB_ALIGNED(8); #endif /* ! GRUB_EFI_EMU_RUNTIME_HEADER */ diff --git a/include/grub/types.h b/include/grub/types.h -index 035a4b528fc..2fc4be4039a 100644 +index b36b26a79d4..30e57254889 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -29,6 +29,7 @@ diff --git a/0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch b/0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch deleted file mode 100644 index f0e491e..0000000 --- a/0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Mark Salter -Date: Mon, 17 Apr 2017 08:44:29 -0400 -Subject: [PATCH] arm64: make sure fdt has #address-cells and #size-cells - properties - -Recent upstream changes to kexec-tools relies on #address-cells -and #size-cells properties in the FDT. If grub2 needs to create -a chosen node, it is likely because firmware did not provide one. -In that case, set #address-cells and #size-cells properties to -make sure they exist. ---- - grub-core/loader/arm64/linux.c | 16 +++++++++++++++- - 1 file changed, 15 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 04994d5c67d..4c0a09c06de 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -81,7 +81,21 @@ finalize_params_linux (void) - - node = grub_fdt_find_subnode (fdt, 0, "chosen"); - if (node < 0) -- node = grub_fdt_add_subnode (fdt, 0, "chosen"); -+ { -+ /* -+ * If we have to create a chosen node, Make sure we -+ * have #address-cells and #size-cells properties. -+ */ -+ retval = grub_fdt_set_prop32(fdt, 0, "#address-cells", 2); -+ if (retval) -+ goto failure; -+ -+ retval = grub_fdt_set_prop32(fdt, 0, "#size-cells", 2); -+ if (retval) -+ goto failure; -+ -+ node = grub_fdt_add_subnode (fdt, 0, "chosen"); -+ } - - if (node < 1) - goto failure; diff --git a/0071-Add-BLS-support-to-grub-mkconfig.patch b/0071-Add-BLS-support-to-grub-mkconfig.patch new file mode 100644 index 0000000..15ce7b3 --- /dev/null +++ b/0071-Add-BLS-support-to-grub-mkconfig.patch @@ -0,0 +1,393 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 9 Dec 2016 15:40:29 -0500 +Subject: [PATCH] Add BLS support to grub-mkconfig + +GRUB now has BootLoaderSpec support, the user can choose to use this by +setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup, +the boot menu entries are not added to the grub.cfg, instead BLS config +files are parsed by blscfg command and the entries created dynamically. + +A 10_linux_bls grub.d snippet to generate menu entries from BLS files +is also added that can be used on platforms where the bootloader doesn't +have BLS support and only can parse a normal grub configuration file. + +Portions of the 10_linux_bls were taken from the ostree-grub-generator +script that's included in the OSTree project. + +Fixes to support multi-devices and generate a BLS section even if no +kernels are found in the boot directory were proposed by Yclept Nemo +and Tom Gundersen respectively. + +Signed-off-by: Peter Jones +Signed-off-by: Javier Martinez Canillas +--- + util/grub-mkconfig.8 | 4 + + util/grub-mkconfig.in | 9 +- + util/grub-mkconfig_lib.in | 20 ++++- + util/grub.d/10_linux.in | 223 +++++++++++++++++++++++++++++++++++++++++++++- + 4 files changed, 251 insertions(+), 5 deletions(-) + +diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8 +index a2d1f577b9b..434fa4deda4 100644 +--- a/util/grub-mkconfig.8 ++++ b/util/grub-mkconfig.8 +@@ -13,5 +13,9 @@ + \fB--output\fR=\fIFILE\fR + Write generated output to \fIFILE\fR. + ++.TP ++\fB--no-grubenv-update\fR ++Do not update variables in the grubenv file. ++ + .SH SEE ALSO + .BR "info grub" +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index e671ce68aec..1a70b7ea056 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" + export TEXTDOMAIN=@PACKAGE@ + export TEXTDOMAINDIR="@localedir@" + ++export GRUB_GRUBENV_UPDATE="yes" ++ + . "${pkgdatadir}/grub-mkconfig_lib" + + # Usage: usage +@@ -59,6 +61,7 @@ usage () { + gettext "Generate a grub config file"; echo + echo + print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")" ++ print_option_help "--no-grubenv-update" "$(gettext "do not update variables in the grubenv file")" + print_option_help "-h, --help" "$(gettext "print this message and exit")" + print_option_help "-V, --version" "$(gettext "print the version information and exit")" + echo +@@ -94,6 +97,9 @@ do + --output=*) + grub_cfg=`echo "$option" | sed 's/--output=//'` + ;; ++ --no-grubenv-update) ++ GRUB_GRUBENV_UPDATE="no" ++ ;; + -*) + gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 + usage +@@ -256,7 +262,8 @@ export GRUB_DEFAULT \ + GRUB_OS_PROBER_SKIP_LIST \ + GRUB_DISABLE_SUBMENU \ + GRUB_DEFAULT_DTB \ +- SUSE_BTRFS_SNAPSHOT_BOOTING ++ SUSE_BTRFS_SNAPSHOT_BOOTING \ ++ GRUB_ENABLE_BLSCFG + + if test "x${grub_cfg}" != "x"; then + rm -f "${grub_cfg}.new" +diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in +index fafeac95061..4e6534a41f6 100644 +--- a/util/grub-mkconfig_lib.in ++++ b/util/grub-mkconfig_lib.in +@@ -30,6 +30,9 @@ fi + if test "x$grub_file" = x; then + grub_file="${bindir}/@grub_file@" + fi ++if test "x$grub_editenv" = x; then ++ grub_editenv="${bindir}/@grub_editenv@" ++fi + if test "x$grub_mkrelpath" = x; then + grub_mkrelpath="${bindir}/@grub_mkrelpath@" + fi +@@ -125,8 +128,19 @@ EOF + fi + } + ++prepare_grub_to_access_device_with_variable () ++{ ++ device_variable="$1" ++ shift ++ prepare_grub_to_access_device "$@" ++ unset "device_variable" ++} ++ + prepare_grub_to_access_device () + { ++ if [ -z "$device_variable" ]; then ++ device_variable="root" ++ fi + old_ifs="$IFS" + IFS=' + ' +@@ -161,15 +175,15 @@ prepare_grub_to_access_device () + # otherwise set root as per value in device.map. + fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`" + if [ "x$fs_hint" != x ]; then +- echo "set root='$fs_hint'" ++ echo "set ${device_variable}='$fs_hint'" + fi + if [ "x${GRUB_DISABLE_UUID}" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then + hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= + if [ "x$hints" != x ]; then + echo "if [ x\$feature_platform_search_hint = xy ]; then" +- echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" ++ echo " search --no-floppy --fs-uuid --set=${device_variable} ${hints} ${fs_uuid}" + echo "else" +- echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}" ++ echo " search --no-floppy --fs-uuid --set=${device_variable} ${fs_uuid}" + echo "fi" + else + echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}" +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index cbfaca34cc7..68adb55d893 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -82,6 +82,223 @@ case x"$GRUB_FS" in + ;; + esac + ++populate_header_warn() ++{ ++if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then ++ bls_parser="10_linux script" ++else ++ bls_parser="blscfg command" ++fi ++cat </dev/null | tac)) || : ++ ++ echo "${files[@]}" ++} ++ ++update_bls_cmdline() ++{ ++ local cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++ local -a files=($(get_sorted_bls)) ++ ++ for bls in "${files[@]}"; do ++ local options="${cmdline}" ++ if [ -z "${bls##*debug*}" ]; then ++ options="${options} ${GRUB_CMDLINE_LINUX_DEBUG}" ++ fi ++ options="$(echo "${options}" | sed -e 's/\//\\\//g')" ++ sed -i -e "s/^options.*/options ${options}/" "${blsdir}/${bls}.conf" ++ done ++} ++ ++populate_menu() ++{ ++ local -a files=($(get_sorted_bls)) ++ ++ gettext_printf "Generating boot entries from BLS files...\n" >&2 ++ ++ for bls in "${files[@]}"; do ++ read_config "${blsdir}/${bls}.conf" ++ ++ menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" ++ menu="${menu}\t linux ${linux} ${options}\n" ++ if [ -n "${initrd}" ] ; then ++ menu="${menu}\t initrd ${boot_prefix}${initrd}\n" ++ fi ++ menu="${menu}}\n\n" ++ done ++ # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation ++ printf "$menu" ++} ++ ++# Make BLS the default if GRUB_ENABLE_BLSCFG was not set and grubby is not installed. ++if [ -z "${GRUB_ENABLE_BLSCFG}" ] && [ -z "$(which new-kernel-pkg 2> /dev/null)" ]; then ++ GRUB_ENABLE_BLSCFG="true" ++fi ++ ++if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then ++ if [ x$dirname = x/ ]; then ++ if [ -z "${prepare_root_cache}" ]; then ++ prepare_grub_to_access_device ${GRUB_DEVICE} ++ fi ++ else ++ if [ -z "${prepare_boot_cache}" ]; then ++ prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} ++ fi ++ fi ++ ++ if [ -d /sys/firmware/efi ]; then ++ bootefi_device="`${grub_probe} --target=device /boot/efi/`" ++ prepare_grub_to_access_device_with_variable boot ${bootefi_device} ++ else ++ boot_device="`${grub_probe} --target=device /boot/`" ++ prepare_grub_to_access_device_with_variable boot ${boot_device} ++ fi ++ ++ arch="$(uname -m)" ++ if [ "x${arch}" = "xppc64le" ] && [ -d /sys/firmware/opal ]; then ++ ++ BLS_POPULATE_MENU="true" ++ petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" ++ ++ if test -e ${petitboot_path}; then ++ read -r -d '' petitboot_version < ${petitboot_path} ++ petitboot_version="$(echo ${petitboot_version//v})" ++ ++ if test -n ${petitboot_version}; then ++ major_version="$(echo ${petitboot_version} | cut -d . -f1)" ++ minor_version="$(echo ${petitboot_version} | cut -d . -f2)" ++ ++ re='^[0-9]+$' ++ if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] && ++ ([[ ${major_version} -gt 1 ]] || ++ [[ ${major_version} -eq 1 && ++ ${minor_version} -ge 8 ]]); then ++ BLS_POPULATE_MENU="false" ++ fi ++ fi ++ fi ++ fi ++ ++ populate_header_warn ++ ++ cat << EOF ++# The kernelopts variable should be defined in the grubenv file. But to ensure that menu ++# entries populated from BootLoaderSpec files that use this variable work correctly even ++# without a grubenv file, define a fallback kernelopts variable if this has not been set. ++# ++# The kernelopts variable in the grubenv file can be modified using the grubby tool or by ++# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX ++# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both ++# the kernelopts variable in the grubenv file and the fallback kernelopts variable. ++if [ -z "\${kernelopts}" ]; then ++ set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++fi ++EOF ++ ++ update_bls_cmdline ++ ++ if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then ++ populate_menu ++ else ++ cat << EOF ++ ++insmod blscfg ++blscfg ++EOF ++ fi ++ ++ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then ++ blsdir="/boot/loader/entries" ++ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})" ++ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then ++ blsdir=$(make_system_path_relative_to_its_root "${blsdir}") ++ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then ++ ${grub_editenv} - set blsdir="${blsdir}" ++ fi ++ fi ++ ++ if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then ++ ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ++ fi ++ ++ if [ -n "${GRUB_DEFAULT_DTB}" ]; then ++ ${grub_editenv} - set devicetree="${GRUB_DEFAULT_DTB}" ++ fi ++ ++ if [ -n "${GRUB_SAVEDEFAULT}" ]; then ++ ${grub_editenv} - set save_default="${GRUB_SAVEDEFAULT}" ++ fi ++ fi ++ ++ exit 0 ++fi ++ + mktitle () + { + local title_type +@@ -121,6 +338,7 @@ linux_entry () + if [ -z "$boot_device_id" ]; then + boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" + fi ++ + if [ x$type != xsimple ] ; then + title=$(mktitle "$type" "$version") + if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then +@@ -224,6 +442,7 @@ is_top_level=true + while [ "x$list" != "x" ] ; do + linux=`version_find_latest $list` + gettext_printf "Found linux image: %s\n" "$linux" >&2 ++ + basename=`basename $linux` + dirname=`dirname $linux` + rel_dirname=`make_system_path_relative_to_its_root $dirname` +@@ -262,7 +481,9 @@ while [ "x$list" != "x" ] ; do + for i in ${initrd}; do + initrd_display="${initrd_display} ${dirname}/${i}" + done +- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 ++ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then ++ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 ++ fi + fi + + fdt= diff --git a/0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch b/0072-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch similarity index 89% rename from 0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch rename to 0072-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch index 204abbc..9ff4c8b 100644 --- a/0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch +++ b/0072-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch @@ -12,10 +12,10 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 04371ac49f2..636f97e1ba1 100644 +index a3e215155bd..c60601b699d 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1103,7 +1103,7 @@ static void __attribute__ ((noreturn)) +@@ -1201,7 +1201,7 @@ static void __attribute__ ((noreturn)) grub_abort (void) { #ifndef GRUB_UTIL diff --git a/0072-print-more-debug-info-in-our-module-loader.patch b/0072-print-more-debug-info-in-our-module-loader.patch deleted file mode 100644 index 48f48e3..0000000 --- a/0072-print-more-debug-info-in-our-module-loader.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 1 May 2017 11:19:40 -0400 -Subject: [PATCH] print more debug info in our module loader. - -Signed-off-by: Peter Jones ---- - grub-core/kern/efi/efi.c | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 370ce03c5d7..a1af9b46559 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -313,13 +313,23 @@ grub_efi_modules_addr (void) - } - - if (i == coff_header->num_sections) -- return 0; -+ { -+ grub_dprintf("sections", "section %d is last section; invalid.\n", i); -+ return 0; -+ } - - info = (struct grub_module_info *) ((char *) image->image_base - + section->virtual_address); -- if (info->magic != GRUB_MODULE_MAGIC) -- return 0; -+ if (section->name[0] != '.' && info->magic != GRUB_MODULE_MAGIC) -+ { -+ grub_dprintf("sections", -+ "section %d has bad magic %08x, should be %08x\n", -+ i, info->magic, GRUB_MODULE_MAGIC); -+ return 0; -+ } - -+ grub_dprintf("sections", "returning section info for section %d: \"%s\"\n", -+ i, section->name); - return (grub_addr_t) info; - } - diff --git a/0097-Add-linux-and-initrd-commands-for-grub-emu.patch b/0073-Add-linux-and-initrd-commands-for-grub-emu.patch similarity index 96% rename from 0097-Add-linux-and-initrd-commands-for-grub-emu.patch rename to 0073-Add-linux-and-initrd-commands-for-grub-emu.patch index f956667..dd69b13 100644 --- a/0097-Add-linux-and-initrd-commands-for-grub-emu.patch +++ b/0073-Add-linux-and-initrd-commands-for-grub-emu.patch @@ -18,10 +18,10 @@ to the kexec command line tool, to allow booting the selected menu entry. create mode 100644 grub-core/loader/emu/linux.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index ebc558019cd..528f76a8c8e 100644 +index 058c88ac3af..5354f9613d3 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -1802,7 +1802,6 @@ module = { +@@ -1826,7 +1826,6 @@ module = { common = loader/linux.c; common = lib/cmdline.c; @@ -52,7 +52,7 @@ index 55ea5a11ccd..846fe9715ec 100644 case ARGP_KEY_ARG: { diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index 19cd007d448..245b69cab51 100644 +index 0ff13bcaf8c..eeea092752d 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -39,6 +39,7 @@ @@ -72,7 +72,7 @@ index 19cd007d448..245b69cab51 100644 } void * -@@ -142,6 +143,9 @@ void +@@ -154,6 +155,9 @@ void __attribute__ ((noreturn)) grub_exit (int rc) { @@ -82,7 +82,7 @@ index 19cd007d448..245b69cab51 100644 exit (rc < 0 ? 1 : rc); } #endif -@@ -203,3 +207,15 @@ grub_util_load_image (const char *path, char *buf) +@@ -215,3 +219,15 @@ grub_util_load_image (const char *path, char *buf) fclose (fp); } @@ -320,10 +320,10 @@ index cfb1e2b5661..a61568e36e9 100644 char * grub_util_path_concat (size_t n, ...); diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h -index ce464cfd007..5ef4f79e689 100644 +index ff9c48a6490..01056954b96 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h -@@ -56,6 +56,9 @@ void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format ( +@@ -57,6 +57,9 @@ void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format ( void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2), noreturn)); @@ -334,10 +334,10 @@ index ce464cfd007..5ef4f79e689 100644 #ifdef HAVE_DEVICE_MAPPER diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index c6ba5b2d763..5ff3afd62fa 100644 +index ee88e44e97a..80e7a83edf9 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am -@@ -304,6 +304,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/net.h +@@ -307,6 +307,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/net.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostfile.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h diff --git a/0098-Add-grub2-switch-to-blscfg.patch b/0074-Add-grub2-switch-to-blscfg.patch similarity index 87% rename from 0098-Add-grub2-switch-to-blscfg.patch rename to 0074-Add-grub2-switch-to-blscfg.patch index 80c4042..ce40e90 100644 --- a/0098-Add-grub2-switch-to-blscfg.patch +++ b/0074-Add-grub2-switch-to-blscfg.patch @@ -11,13 +11,13 @@ Signed-off-by: Jan Hlavac Makefile.util.def | 7 + util/grub-set-password.in | 2 +- util/grub-switch-to-blscfg.8 | 33 +++++ - util/grub-switch-to-blscfg.in | 314 ++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 355 insertions(+), 1 deletion(-) + util/grub-switch-to-blscfg.in | 317 ++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 358 insertions(+), 1 deletion(-) create mode 100644 util/grub-switch-to-blscfg.8 create mode 100644 util/grub-switch-to-blscfg.in diff --git a/Makefile.util.def b/Makefile.util.def -index a61613656d1..f55473c76aa 100644 +index cdd2f51fe4b..afc4d7b0c3e 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -1364,6 +1364,13 @@ program = { @@ -87,10 +87,10 @@ index 00000000000..9a886282976 +.BR "info grub" diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in new file mode 100644 -index 00000000000..49b3985fadb +index 00000000000..a851424beb2 --- /dev/null +++ b/util/grub-switch-to-blscfg.in -@@ -0,0 +1,314 @@ +@@ -0,0 +1,317 @@ +#! /bin/sh +# +# Set a default boot entry for GRUB. @@ -283,7 +283,7 @@ index 00000000000..49b3985fadb +mkbls() { + local kernelver=$1 && shift + local datetime=$1 && shift -+ local bootprefix=$1 && shift ++ local kernelopts=$1 && shift + + local debugname="" + local debugid="" @@ -302,10 +302,9 @@ index 00000000000..49b3985fadb + cat <"${bls_target}" -+ fi ++ mkbls "${kernelver}" \ ++ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ ++ "${bootprefix}" "${cmdline}" >"${bls_target}" + + if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then + bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")" + cp -aT "${bls_target}" "${bls_debug}" + title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" -+ blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" ++ options="$(echo "${cmdline} ${GRUB_CMDLINE_LINUX_DEBUG}" | sed -e 's/\//\\\//g')" + sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" -+ sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" -+ sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" ++ sed -i -e "s/^options.*/options ${options}/" "${bls_debug}" + fi + done + @@ -359,6 +349,19 @@ index 00000000000..49b3985fadb + fi +} + ++# The grub2 EFI binary is not copied to the ESP as a part of an ostree ++# transaction. Make sure a grub2 version with BLS support is installed ++# but only do this if the blsdir is not set, to make sure that the BLS ++# parsing module will search for the BLS snippets in the default path. ++if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \ ++ ! ${grub_editenv} - list | grep -q blsdir && \ ++ mountpoint -q /boot; then ++ grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" ++ install -m 700 ${grub_binary} ${grubdir} || exit 1 ++ # Create a hidden file to indicate that grub2 now has BLS support. ++ touch /boot/grub2/.grub2-blscfg-supported ++fi ++ +GENERATE=0 +if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \ + | grep -vq '^GRUB_ENABLE_BLSCFG="*true"*\s*$' ; then @@ -388,13 +391,13 @@ index 00000000000..49b3985fadb + + if [ -n "${mod_dir}" ]; then + for mod in blscfg increment; do -+ cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 ++ install -m 700 ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 + done + fi + + cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" + if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then -+ cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" ++ install -m 700 "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" + sed -i"${backupsuffix}" \ + -e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \ + "${etcdefaultgrub}" diff --git a/0100-make-better-backtraces.patch b/0075-make-better-backtraces.patch similarity index 96% rename from 0100-make-better-backtraces.patch rename to 0075-make-better-backtraces.patch index 56f4c4b..a65af3d 100644 --- a/0100-make-better-backtraces.patch +++ b/0075-make-better-backtraces.patch @@ -38,10 +38,10 @@ Signed-off-by: Peter Jones delete mode 100644 grub-core/lib/i386/backtrace.c diff --git a/Makefile.util.def b/Makefile.util.def -index f55473c76aa..c13ca685ce1 100644 +index afc4d7b0c3e..41906486a71 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -49,6 +49,12 @@ library = { +@@ -51,6 +51,12 @@ library = { common = grub-core/partmap/msdos.c; common = grub-core/fs/proc.c; common = grub-core/fs/archelp.c; @@ -55,13 +55,13 @@ index f55473c76aa..c13ca685ce1 100644 library = { diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 528f76a8c8e..49c5dc4c3b7 100644 +index 5354f9613d3..4b7c45a7b06 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -140,6 +140,12 @@ kernel = { - common = kern/rescue_parser.c; +@@ -142,6 +142,12 @@ kernel = { common = kern/rescue_reader.c; common = kern/term.c; + common = kern/verifiers.c; + common = kern/backtrace.c; + + x86 = kern/i386/backtrace.c; @@ -71,7 +71,7 @@ index 528f76a8c8e..49c5dc4c3b7 100644 noemu = kern/compiler-rt.c; noemu = kern/mm.c; -@@ -186,9 +192,6 @@ kernel = { +@@ -188,9 +194,6 @@ kernel = { softdiv = lib/division.c; @@ -81,7 +81,7 @@ index 528f76a8c8e..49c5dc4c3b7 100644 i386 = kern/i386/dl.c; i386_xen = kern/i386/dl.c; i386_xen_pvh = kern/i386/dl.c; -@@ -2376,15 +2379,12 @@ module = { +@@ -2398,15 +2401,12 @@ module = { module = { name = backtrace; @@ -331,7 +331,7 @@ index 00000000000..4a82e865cc6 + grub_backtrace (skip + 1); +} diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index d7718d26abc..2e57e5e6829 100644 +index 7afb9e6f724..88d2077709e 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -124,6 +124,50 @@ grub_dl_resolve_symbol (const char *name) @@ -559,11 +559,11 @@ index 0cd2a627231..937c1bc44cb 100644 #ifdef __sparc__ diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index e758ab3416d..5c2d2039d0b 100644 +index c60601b699d..a432a6be54a 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1110,15 +1110,15 @@ grub_xasprintf (const char *fmt, ...) - } +@@ -1197,15 +1197,15 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected) + /* Abort GRUB. This function does not return. */ -static void __attribute__ ((noreturn)) @@ -584,7 +584,7 @@ index e758ab3416d..5c2d2039d0b 100644 #ifndef GRUB_UTIL if (grub_term_inputs) -@@ -1145,6 +1145,7 @@ grub_fatal (const char *fmt, ...) +@@ -1232,6 +1232,7 @@ grub_fatal (const char *fmt, ...) { va_list ap; @@ -593,10 +593,10 @@ index e758ab3416d..5c2d2039d0b 100644 grub_vprintf (_(fmt), ap); va_end (ap); diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index ee88ff61187..002cbfa4f3d 100644 +index c070afc621f..d8c8377578b 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c -@@ -95,13 +95,13 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r) +@@ -97,13 +97,13 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r) break; if (! *r) @@ -787,10 +787,10 @@ index 395519762f0..275cf85e2d3 100644 #endif diff --git a/include/grub/dl.h b/include/grub/dl.h -index 90dc9bb1017..4fe2b524f73 100644 +index 91933b85f2c..2f76e6b0437 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h -@@ -257,6 +257,8 @@ grub_dl_is_persistent (grub_dl_t mod) +@@ -259,6 +259,8 @@ grub_dl_is_persistent (grub_dl_t mod) #endif @@ -800,10 +800,10 @@ index 90dc9bb1017..4fe2b524f73 100644 int isfunc, grub_dl_t mod); diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index 133a37c8d03..e5a5f436709 100644 +index abbca5ea335..300a9766cda 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h -@@ -110,6 +110,9 @@ grub_addr_t grub_modules_get_end (void); +@@ -111,6 +111,9 @@ grub_addr_t grub_modules_get_end (void); #endif @@ -897,7 +897,7 @@ index 03b916f0534..701bf63abcf 100644 ba codestart mov %o4, %o0 diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index 5ff3afd62fa..d9ad30052f1 100644 +index 80e7a83edf9..f512573c0da 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -66,6 +66,7 @@ CLEANFILES += grub_script.yy.c grub_script.yy.h diff --git a/0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch b/0076-normal-don-t-draw-our-startup-message-if-debug-is-se.patch similarity index 89% rename from 0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch rename to 0076-normal-don-t-draw-our-startup-message-if-debug-is-se.patch index 6777636..9922f2b 100644 --- a/0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch +++ b/0076-normal-don-t-draw-our-startup-message-if-debug-is-se.patch @@ -8,10 +8,10 @@ Subject: [PATCH] normal: don't draw our startup message if debug is set 1 file changed, 3 insertions(+) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 2fe6743399d..f7ee912e715 100644 +index d5968797f4f..e349303c29b 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -425,6 +425,9 @@ grub_normal_reader_init (int nested) +@@ -432,6 +432,9 @@ grub_normal_reader_init (int nested) const char *msg_esc = _("ESC at any time exits."); char *msg_formatted; diff --git a/0102-Work-around-some-minor-include-path-weirdnesses.patch b/0077-Work-around-some-minor-include-path-weirdnesses.patch similarity index 100% rename from 0102-Work-around-some-minor-include-path-weirdnesses.patch rename to 0077-Work-around-some-minor-include-path-weirdnesses.patch diff --git a/0103-Make-it-possible-to-enabled-build-id-sha1.patch b/0078-Make-it-possible-to-enabled-build-id-sha1.patch similarity index 93% rename from 0103-Make-it-possible-to-enabled-build-id-sha1.patch rename to 0078-Make-it-possible-to-enabled-build-id-sha1.patch index d77b6f6..c1aa516 100644 --- a/0103-Make-it-possible-to-enabled-build-id-sha1.patch +++ b/0078-Make-it-possible-to-enabled-build-id-sha1.patch @@ -10,10 +10,10 @@ Signed-off-by: Peter Jones 2 files changed, 27 insertions(+) diff --git a/configure.ac b/configure.ac -index eb851b8d722..8ee18ba159a 100644 +index 6c16968ad9c..f4cfd06cbe6 100644 --- a/configure.ac +++ b/configure.ac -@@ -1414,7 +1414,15 @@ grub_PROG_TARGET_CC +@@ -1470,7 +1470,15 @@ grub_PROG_TARGET_CC if test "x$TARGET_APPLE_LINKER" != x1 ; then grub_PROG_OBJCOPY_ABSOLUTE fi @@ -30,7 +30,7 @@ index eb851b8d722..8ee18ba159a 100644 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then if test ! -z "$TARGET_IMG_LDSCRIPT"; then diff --git a/acinclude.m4 b/acinclude.m4 -index 78cdf6e1d01..242e829ff23 100644 +index 6e14bb553c6..21238fcfd03 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -136,6 +136,25 @@ if test "x$grub_cv_prog_ld_build_id_none" = xyes; then diff --git a/0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch b/0079-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch similarity index 89% rename from 0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch rename to 0079-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch index b434d4c..a8a757e 100644 --- a/0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch +++ b/0079-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch @@ -13,10 +13,10 @@ Signed-off-by: Peter Jones 2 files changed, 20 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 5c2d2039d0b..0e89c483d5e 100644 +index a432a6be54a..9a2fae6398e 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -190,6 +190,24 @@ grub_real_dprintf (const char *file, const int line, const char *condition, +@@ -191,6 +191,24 @@ grub_real_dprintf (const char *file, const int line, const char *condition, } } @@ -42,10 +42,10 @@ index 5c2d2039d0b..0e89c483d5e 100644 int diff --git a/include/grub/misc.h b/include/grub/misc.h -index 4a4f485a5f6..960097fbd06 100644 +index fd18e6320b8..3adc4036e3b 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h -@@ -372,6 +372,8 @@ void EXPORT_FUNC(grub_real_dprintf) (const char *file, +@@ -345,6 +345,8 @@ void EXPORT_FUNC(grub_real_dprintf) (const char *file, const int line, const char *condition, const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 4, 5))); diff --git a/0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch b/0080-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch similarity index 90% rename from 0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch rename to 0080-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch index 09cc7c6..75de764 100644 --- a/0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch +++ b/0080-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch @@ -20,7 +20,7 @@ Signed-off-by: Peter Jones 4 files changed, 78 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 2e57e5e6829..6a5e7706143 100644 +index 88d2077709e..9557254035e 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -501,6 +501,23 @@ grub_dl_find_section (Elf_Ehdr *e, const char *name) @@ -47,7 +47,7 @@ index 2e57e5e6829..6a5e7706143 100644 /* Me, Vladimir Serbinenko, hereby I add this module check as per new GNU module policy. Note that this license check is informative only. -@@ -644,6 +661,37 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) +@@ -653,6 +670,37 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) return GRUB_ERR_NONE; } @@ -85,7 +85,7 @@ index 2e57e5e6829..6a5e7706143 100644 /* Load a module from core memory. */ grub_dl_t -@@ -703,6 +751,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) +@@ -712,6 +760,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) grub_dprintf ("modules", "module name: %s\n", mod->name); grub_dprintf ("modules", "init function: %p\n", mod->init); @@ -95,10 +95,10 @@ index 2e57e5e6829..6a5e7706143 100644 { grub_dl_unload (mod); diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 2cf6a5ad526..19054b1465f 100644 +index ae9885edb84..d6a2fb57789 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -283,7 +283,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, +@@ -296,7 +296,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, /* Search the mods section from the PE32/PE32+ image. This code uses a PE32 header, but should work with PE32+ as well. */ grub_addr_t @@ -107,7 +107,7 @@ index 2cf6a5ad526..19054b1465f 100644 { grub_efi_loaded_image_t *image; struct grub_pe32_header *header; -@@ -308,7 +308,7 @@ grub_efi_modules_addr (void) +@@ -321,7 +321,7 @@ grub_efi_modules_addr (void) i < coff_header->num_sections; i++, section++) { @@ -117,10 +117,10 @@ index 2cf6a5ad526..19054b1465f 100644 } diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index 71d2279a0c1..e6183a4c44d 100644 +index 6d39bd3ad29..2d12e6188fd 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c -@@ -59,10 +59,33 @@ grub_efi_env_init (void) +@@ -115,10 +115,33 @@ grub_efi_env_init (void) grub_free (envblk_s.buf); } @@ -155,7 +155,7 @@ index 71d2279a0c1..e6183a4c44d 100644 /* First of all, initialize the console so that GRUB can display messages. */ grub_console_init (); -@@ -74,6 +97,7 @@ grub_efi_init (void) +@@ -142,6 +165,7 @@ grub_efi_init (void) 0, 0, 0, NULL); grub_efi_env_init (); @@ -164,10 +164,10 @@ index 71d2279a0c1..e6183a4c44d 100644 } diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 5e2b479daec..8ca3981d7a1 100644 +index 03f9a9d0118..2e0691454b1 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h -@@ -132,7 +132,7 @@ grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); +@@ -138,7 +138,7 @@ grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, char *args); #endif diff --git a/0106-Fixup-for-newer-compiler.patch b/0081-Fixup-for-newer-compiler.patch similarity index 92% rename from 0106-Fixup-for-newer-compiler.patch rename to 0081-Fixup-for-newer-compiler.patch index ae5ac89..12dd193 100644 --- a/0106-Fixup-for-newer-compiler.patch +++ b/0081-Fixup-for-newer-compiler.patch @@ -9,10 +9,10 @@ Subject: [PATCH] Fixup for newer compiler 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index ba99d04f8ed..9cd7f4bdf65 100644 +index 2b21cbaa67e..4cc86e9b79e 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -215,7 +215,7 @@ struct grub_btrfs_inode +@@ -218,7 +218,7 @@ struct grub_btrfs_inode grub_uint64_t size; grub_uint8_t dummy2[0x70]; struct grub_btrfs_time mtime; diff --git a/0107-Don-t-attempt-to-export-the-start-and-_start-symbols.patch b/0082-Don-t-attempt-to-export-the-start-and-_start-symbols.patch similarity index 94% rename from 0107-Don-t-attempt-to-export-the-start-and-_start-symbols.patch rename to 0082-Don-t-attempt-to-export-the-start-and-_start-symbols.patch index f6c1185..0e925ee 100644 --- a/0107-Don-t-attempt-to-export-the-start-and-_start-symbols.patch +++ b/0082-Don-t-attempt-to-export-the-start-and-_start-symbols.patch @@ -26,10 +26,10 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 2 insertions(+) diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index e5a5f436709..de48cd44ccb 100644 +index 300a9766cda..55849777eaa 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h -@@ -110,8 +110,10 @@ grub_addr_t grub_modules_get_end (void); +@@ -111,8 +111,10 @@ grub_addr_t grub_modules_get_end (void); #endif diff --git a/0108-Fixup-for-newer-compiler.patch b/0083-Fixup-for-newer-compiler.patch similarity index 96% rename from 0108-Fixup-for-newer-compiler.patch rename to 0083-Fixup-for-newer-compiler.patch index e35dbdb..11ed6e5 100644 --- a/0108-Fixup-for-newer-compiler.patch +++ b/0083-Fixup-for-newer-compiler.patch @@ -8,7 +8,7 @@ Subject: [PATCH] Fixup for newer compiler 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common -index 4ba729e14d8..5e8ba2ae3b0 100644 +index 191b1a70c6b..5f0ef969857 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding diff --git a/0109-Add-support-for-non-Ethernet-network-cards.patch b/0084-Add-support-for-non-Ethernet-network-cards.patch similarity index 97% rename from 0109-Add-support-for-non-Ethernet-network-cards.patch rename to 0084-Add-support-for-non-Ethernet-network-cards.patch index dc89c99..62f2a11 100644 --- a/0109-Add-support-for-non-Ethernet-network-cards.patch +++ b/0084-Add-support-for-non-Ethernet-network-cards.patch @@ -271,10 +271,10 @@ index 54306e3b16d..67b409a8acc 100644 /* Change operation to REPLY and send packet */ send_ethernet_packet (inf, &nb_reply, target, GRUB_NET_ETHERTYPE_ARP); diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 8c969595a7b..3cf6dbf0e72 100644 +index 8d9edaac447..dd5c8d04da9 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c -@@ -269,7 +269,6 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -233,7 +233,6 @@ grub_net_configure_by_dhcp_ack (const char *name, int is_def, char **device, char **path) { grub_net_network_level_address_t addr; @@ -282,7 +282,7 @@ index 8c969595a7b..3cf6dbf0e72 100644 struct grub_net_network_level_interface *inter; int mask = -1; char server_ip[sizeof ("xxx.xxx.xxx.xxx")]; -@@ -286,12 +285,8 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -250,12 +249,8 @@ grub_net_configure_by_dhcp_ack (const char *name, if (path) *path = 0; @@ -297,7 +297,7 @@ index 8c969595a7b..3cf6dbf0e72 100644 if (!inter) return 0; -@@ -601,7 +596,9 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) +@@ -567,7 +562,9 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) grub_memset (pack, 0, sizeof (*pack)); pack->opcode = 1; pack->hw_type = 1; @@ -308,7 +308,7 @@ index 8c969595a7b..3cf6dbf0e72 100644 err = grub_get_datetime (&date); if (err || !grub_datetime2unixtime (&date, &t)) { -@@ -614,7 +611,7 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) +@@ -580,7 +577,7 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) else pack->ident = iface->xid; @@ -318,10 +318,10 @@ index 8c969595a7b..3cf6dbf0e72 100644 grub_netbuff_push (nb, sizeof (*udph)); diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index a57189e8bb3..4444e8e60ee 100644 +index 173fb63153c..a673bea807a 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -280,6 +280,9 @@ grub_efinet_findcards (void) +@@ -279,6 +279,9 @@ grub_efinet_findcards (void) /* This should not happen... Why? */ continue; @@ -331,7 +331,7 @@ index a57189e8bb3..4444e8e60ee 100644 if (net->mode->state == GRUB_EFI_NETWORK_STOPPED && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) continue; -@@ -316,10 +319,11 @@ grub_efinet_findcards (void) +@@ -315,10 +318,11 @@ grub_efinet_findcards (void) card->name = grub_xasprintf ("efinet%d", i++); card->driver = &efidriver; card->flags = 0; @@ -627,10 +627,10 @@ index ea5edf8f1f6..a5896f6dc26 100644 grub_net_process_dhcp (nb, inf); grub_netbuff_free (nb); diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 5366e443d2a..6468eb24596 100644 +index 22f2689aaeb..a46f82362ed 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -128,8 +128,9 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf, +@@ -133,8 +133,9 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf, << 48) && proto_addr->ipv6[1] == (grub_be_to_cpu64_compile_time (1)))) { @@ -642,7 +642,7 @@ index 5366e443d2a..6468eb24596 100644 return GRUB_ERR_NONE; } -@@ -137,6 +138,7 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf, +@@ -142,6 +143,7 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf, && ((grub_be_to_cpu64 (proto_addr->ipv6[0]) >> 56) == 0xff)) { hw_addr->type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; @@ -650,7 +650,7 @@ index 5366e443d2a..6468eb24596 100644 hw_addr->mac[0] = 0x33; hw_addr->mac[1] = 0x33; hw_addr->mac[2] = ((grub_be_to_cpu64 (proto_addr->ipv6[1]) >> 24) & 0xff); -@@ -757,23 +759,23 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf) +@@ -762,23 +764,23 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf) void grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str) { @@ -689,7 +689,7 @@ index 5366e443d2a..6468eb24596 100644 } int -@@ -784,13 +786,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, +@@ -789,13 +791,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, return -1; if (a->type > b->type) return +1; @@ -713,7 +713,7 @@ index 5366e443d2a..6468eb24596 100644 int diff --git a/include/grub/net.h b/include/grub/net.h -index 3647012374b..fc1fc44baef 100644 +index 8a05ec4fe7a..af0404db7e3 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -29,7 +29,8 @@ diff --git a/0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch b/0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch deleted file mode 100644 index a53ecb4..0000000 --- a/0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 26 Jun 2017 12:42:57 -0400 -Subject: [PATCH] Don't use dynamic sized arrays since we don't build with - -std=c99 - ---- - grub-core/net/net.c | 17 ++++++++++++++--- - 1 file changed, 14 insertions(+), 3 deletions(-) - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index f24f1fd63f6..5366e443d2a 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -1853,14 +1853,25 @@ grub_net_search_configfile (char *config) - { - /* By the Client UUID. */ - -- char client_uuid_var[sizeof ("net_") + grub_strlen (inf->name) + -- sizeof ("_clientuuid") + 1]; -- grub_snprintf (client_uuid_var, sizeof (client_uuid_var), -+ char *client_uuid_var; -+ grub_size_t client_uuid_var_size; -+ -+ client_uuid_var_size = grub_snprintf (NULL, 0, -+ "net_%s_clientuuid", inf->name); -+ if (client_uuid_var_size <= 0) -+ continue; -+ client_uuid_var_size += 1; -+ client_uuid_var = grub_malloc(client_uuid_var_size); -+ if (!client_uuid_var) -+ continue; -+ grub_snprintf (client_uuid_var, client_uuid_var_size, - "net_%s_clientuuid", inf->name); - - const char *client_uuid; - client_uuid = grub_env_get (client_uuid_var); - -+ grub_free(client_uuid_var); -+ - if (client_uuid) - { - grub_strcpy (suffix, client_uuid); diff --git a/0111-net-read-bracketed-ipv6-addrs-and-port-numbers.patch b/0085-net-read-bracketed-ipv6-addrs-and-port-numbers.patch similarity index 87% rename from 0111-net-read-bracketed-ipv6-addrs-and-port-numbers.patch rename to 0085-net-read-bracketed-ipv6-addrs-and-port-numbers.patch index a2701b3..834b96e 100644 --- a/0111-net-read-bracketed-ipv6-addrs-and-port-numbers.patch +++ b/0085-net-read-bracketed-ipv6-addrs-and-port-numbers.patch @@ -11,14 +11,14 @@ Signed-off-by: Aaron Miller [pjones: various bug fixes] Signed-off-by: Peter Jones --- - grub-core/net/http.c | 27 ++++++++++++---- + grub-core/net/http.c | 25 ++++++++++++--- grub-core/net/net.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--- grub-core/net/tftp.c | 8 +++-- include/grub/net.h | 1 + - 4 files changed, 110 insertions(+), 13 deletions(-) + 4 files changed, 109 insertions(+), 12 deletions(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 5aa4ad3befc..00737c52750 100644 +index b616cf40b1e..12a2632ea55 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -289,7 +289,9 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)), @@ -73,26 +73,24 @@ index 5aa4ad3befc..00737c52750 100644 ptr = nb->tail; err = grub_netbuff_put (nb, sizeof ("\r\nUser-Agent: " PACKAGE_STRING "\r\n") -@@ -390,9 +403,11 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -390,8 +403,10 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) grub_netbuff_put (nb, 2); grub_memcpy (ptr, "\r\n", 2); - data->sock = grub_net_tcp_open (file->device->net->server, - HTTP_PORT, http_receive, -- http_err, http_err, + grub_dprintf ("http", "opening path %s on host %s TCP port %d\n", + data->filename, server, port ? port : HTTP_PORT); + data->sock = grub_net_tcp_open (server, + port ? port : HTTP_PORT, http_receive, -+ http_err, NULL, + http_err, NULL, file); if (!data->sock) - { diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 6468eb24596..2734f70d22f 100644 +index a46f82362ed..0ce5e675ed7 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -439,6 +439,13 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) +@@ -444,6 +444,13 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) grub_uint16_t newip[8]; const char *ptr = val; int word, quaddot = -1; @@ -106,7 +104,7 @@ index 6468eb24596..2734f70d22f 100644 if (ptr[0] == ':' && ptr[1] != ':') return 0; -@@ -477,6 +484,8 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) +@@ -482,6 +489,8 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) grub_memset (&newip[quaddot], 0, (7 - word) * sizeof (newip[0])); } grub_memcpy (ip, newip, 16); @@ -115,7 +113,7 @@ index 6468eb24596..2734f70d22f 100644 if (rest) *rest = ptr; return 1; -@@ -1338,8 +1347,10 @@ grub_net_open_real (const char *name) +@@ -1343,8 +1352,10 @@ grub_net_open_real (const char *name) { grub_net_app_level_t proto; const char *protname, *server; @@ -126,7 +124,7 @@ index 6468eb24596..2734f70d22f 100644 if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0) { -@@ -1377,6 +1388,72 @@ grub_net_open_real (const char *name) +@@ -1382,6 +1393,72 @@ grub_net_open_real (const char *name) return NULL; } @@ -199,7 +197,7 @@ index 6468eb24596..2734f70d22f 100644 for (try = 0; try < 2; try++) { FOR_NET_APP_LEVEL (proto) -@@ -1386,14 +1463,13 @@ grub_net_open_real (const char *name) +@@ -1391,14 +1468,13 @@ grub_net_open_real (const char *name) { grub_net_t ret = grub_zalloc (sizeof (*ret)); if (!ret) @@ -218,7 +216,7 @@ index 6468eb24596..2734f70d22f 100644 ret->fs = &grub_net_fs; return ret; } -@@ -1468,6 +1544,7 @@ grub_net_open_real (const char *name) +@@ -1473,6 +1549,7 @@ grub_net_open_real (const char *name) grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"), name); @@ -227,10 +225,10 @@ index 6468eb24596..2734f70d22f 100644 } diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 0c02a00255b..4920c3a9783 100644 +index 4ab2f5c7357..d54b13f09ff 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c -@@ -333,6 +333,7 @@ tftp_open (struct grub_file *file, const char *filename) +@@ -295,6 +295,7 @@ tftp_open (struct grub_file *file, const char *filename) grub_err_t err; grub_uint8_t *nbd; grub_net_network_level_address_t addr; @@ -238,7 +236,7 @@ index 0c02a00255b..4920c3a9783 100644 data = grub_zalloc (sizeof (*data)); if (!data) -@@ -405,7 +406,10 @@ tftp_open (struct grub_file *file, const char *filename) +@@ -362,14 +363,17 @@ tftp_open (struct grub_file *file, const char *filename) err = grub_net_resolve_address (file->device->net->server, &addr); if (err) { @@ -247,12 +245,11 @@ index 0c02a00255b..4920c3a9783 100644 + grub_dprintf ("tftp", "file_size is %llu, block_size is %llu\n", + (unsigned long long)data->file_size, + (unsigned long long)data->block_size); - destroy_pq (data); grub_free (data); return err; -@@ -413,7 +417,7 @@ tftp_open (struct grub_file *file, const char *filename) + } - grub_dprintf ("tftp", "opening connection\n"); + grub_dprintf("tftp", "opening connection\n"); data->sock = grub_net_udp_open (addr, - TFTP_SERVER_PORT, tftp_receive, + port ? port : TFTP_SERVER_PORT, tftp_receive, @@ -260,7 +257,7 @@ index 0c02a00255b..4920c3a9783 100644 if (!data->sock) { diff --git a/include/grub/net.h b/include/grub/net.h -index fc1fc44baef..fa7a8c39704 100644 +index af0404db7e3..d55d505a03a 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -273,6 +273,7 @@ typedef struct grub_net diff --git a/0112-bootp-New-net_bootp6-command.patch b/0086-bootp-New-net_bootp6-command.patch similarity index 98% rename from 0112-bootp-New-net_bootp6-command.patch rename to 0086-bootp-New-net_bootp6-command.patch index 8cb4ed8..b5f78f8 100644 --- a/0112-bootp-New-net_bootp6-command.patch +++ b/0086-bootp-New-net_bootp6-command.patch @@ -19,12 +19,12 @@ Signed-off-by: Peter Jones 5 files changed, 1002 insertions(+), 209 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 3cf6dbf0e72..85adc9cb447 100644 +index dd5c8d04da9..68c4df681b5 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c -@@ -25,6 +25,98 @@ +@@ -24,6 +24,98 @@ + #include #include - #include #include +#include +#include @@ -121,7 +121,7 @@ index 3cf6dbf0e72..85adc9cb447 100644 struct grub_dhcp_discover_options { -@@ -638,6 +730,584 @@ out: +@@ -604,6 +696,584 @@ out: return err; } @@ -706,7 +706,7 @@ index 3cf6dbf0e72..85adc9cb447 100644 /* * This is called directly from net/ip.c:handle_dgram(), because those * BOOTP/DHCP packets are a bit special due to their improper -@@ -706,6 +1376,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb, +@@ -672,6 +1342,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb, } } @@ -784,7 +784,7 @@ index 3cf6dbf0e72..85adc9cb447 100644 static grub_err_t grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), int argc, char **args) -@@ -931,180 +1672,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), +@@ -897,180 +1638,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), return err; } @@ -1119,7 +1119,7 @@ index 3cf6dbf0e72..85adc9cb447 100644 void grub_bootp_init (void) -@@ -1118,11 +1853,15 @@ grub_bootp_init (void) +@@ -1084,11 +1819,15 @@ grub_bootp_init (void) cmd_getdhcp = grub_register_command ("net_get_dhcp_option", grub_cmd_dhcpopt, N_("VAR INTERFACE NUMBER DESCRIPTION"), N_("retrieve DHCP option and save it into VAR. If VAR is - then print the value.")); @@ -1136,10 +1136,10 @@ index 3cf6dbf0e72..85adc9cb447 100644 grub_unregister_command (cmd_bootp); grub_unregister_command (cmd_dhcp); diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 4444e8e60ee..00d7d37b8de 100644 +index a673bea807a..8e25680db0c 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -394,9 +394,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -393,9 +393,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, pxe_mode = pxe->mode; if (pxe_mode->using_ipv6) { @@ -1149,7 +1149,7 @@ index 4444e8e60ee..00d7d37b8de 100644 grub_dprintf ("efinet", "using ipv6 and dhcpv6\n"); grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n", pxe_mode->dhcp_ack_received ? "yes" : "no", -@@ -404,15 +401,14 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -403,15 +400,14 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (!pxe_mode->dhcp_ack_received) continue; @@ -1224,10 +1224,10 @@ index a5896f6dc26..ce6bdc75c6d 100644 { const struct grub_net_bootp_packet *bootp; diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 955973ed484..71d972a3d89 100644 +index 99628801478..7614b58dca8 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -1507,7 +1507,7 @@ typedef struct grub_efi_pxe_ip_filter +@@ -1532,7 +1532,7 @@ typedef struct grub_efi_pxe_ip_filter { grub_efi_uint8_t filters; grub_efi_uint8_t ip_count; @@ -1237,7 +1237,7 @@ index 955973ed484..71d972a3d89 100644 } grub_efi_pxe_ip_filter_t; diff --git a/include/grub/net.h b/include/grub/net.h -index fa7a8c39704..aedf4b59cfe 100644 +index d55d505a03a..543251f7273 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -451,50 +451,65 @@ struct grub_net_bootp_packet diff --git a/0086-don-t-ignore-const.patch b/0086-don-t-ignore-const.patch deleted file mode 100644 index 81a2025..0000000 --- a/0086-don-t-ignore-const.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 26 Jun 2017 12:43:22 -0400 -Subject: [PATCH] don't ignore const - ---- - grub-core/net/tftp.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index e6d831f1bc9..0c02a00255b 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -307,7 +307,7 @@ static void - grub_normalize_filename (char *normalized, const char *filename) - { - char *dest = normalized; -- char *src = filename; -+ const char *src = filename; - - while (*src != '\0') - { diff --git a/0113-efinet-UEFI-IPv6-PXE-support.patch b/0087-efinet-UEFI-IPv6-PXE-support.patch similarity index 92% rename from 0113-efinet-UEFI-IPv6-PXE-support.patch rename to 0087-efinet-UEFI-IPv6-PXE-support.patch index 50d680a..d8b22b8 100644 --- a/0113-efinet-UEFI-IPv6-PXE-support.patch +++ b/0087-efinet-UEFI-IPv6-PXE-support.patch @@ -15,10 +15,10 @@ Signed-off-by: Ken Lin 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 00d7d37b8de..c3db3285b97 100644 +index 8e25680db0c..014e5bf9802 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -410,6 +410,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -409,6 +409,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, grub_print_error (); if (device && path) grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); @@ -28,10 +28,10 @@ index 00d7d37b8de..c3db3285b97 100644 else { diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 71d972a3d89..186cf398840 100644 +index 7614b58dca8..91ab528e4d0 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -1499,31 +1499,6 @@ typedef union +@@ -1524,31 +1524,6 @@ typedef union grub_efi_pxe_dhcpv6_packet_t dhcpv6; } grub_efi_pxe_packet_t; @@ -63,7 +63,7 @@ index 71d972a3d89..186cf398840 100644 typedef struct grub_efi_pxe_icmp_error { grub_efi_uint8_t type; -@@ -1549,6 +1524,48 @@ typedef struct grub_efi_pxe_tftp_error +@@ -1574,6 +1549,48 @@ typedef struct grub_efi_pxe_tftp_error grub_efi_char8_t error_string[127]; } grub_efi_pxe_tftp_error_t; @@ -112,7 +112,7 @@ index 71d972a3d89..186cf398840 100644 typedef struct grub_efi_pxe_mode { grub_efi_boolean_t started; -@@ -1580,9 +1597,9 @@ typedef struct grub_efi_pxe_mode +@@ -1605,9 +1622,9 @@ typedef struct grub_efi_pxe_mode grub_efi_pxe_packet_t pxe_bis_reply; grub_efi_pxe_ip_filter_t ip_filter; grub_efi_uint32_t arp_cache_entries; diff --git a/0114-grub.texi-Add-net_bootp6-doument.patch b/0088-grub.texi-Add-net_bootp6-doument.patch similarity index 80% rename from 0114-grub.texi-Add-net_bootp6-doument.patch rename to 0088-grub.texi-Add-net_bootp6-doument.patch index fdca976..d7fd91a 100644 --- a/0114-grub.texi-Add-net_bootp6-doument.patch +++ b/0088-grub.texi-Add-net_bootp6-doument.patch @@ -12,18 +12,18 @@ Signed-off-by: Ken Lin 1 file changed, 17 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi -index 960e5f3ba41..495462b8e48 100644 +index aa3a7de9d4f..67bf8523ccb 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -5338,6 +5338,7 @@ This command is only available on AArch64 systems. +@@ -5484,6 +5484,7 @@ This command is only available on AArch64 systems. * net_add_dns:: Add a DNS server * net_add_route:: Add routing entry - * net_bootp:: Perform a bootp autoconfiguration + * net_bootp:: Perform a bootp/DHCP autoconfiguration +* net_bootp6:: Perform a DHCPv6 autoconfiguration * net_del_addr:: Remove IP address from interface * net_del_dns:: Remove a DNS server * net_del_route:: Remove a route entry -@@ -5419,6 +5420,22 @@ Sets environment variable @samp{net_}@var{}@samp{_dhcp_extensionspath} +@@ -5608,6 +5609,22 @@ Sets environment variable @samp{net_}@var{}@samp{_boot_file} @end deffn @@ -44,5 +44,5 @@ index 960e5f3ba41..495462b8e48 100644 + +@end deffn - @node net_del_addr - @subsection net_del_addr + @node net_get_dhcp_option + @subsection net_get_dhcp_option diff --git a/0115-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch b/0089-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch similarity index 88% rename from 0115-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch rename to 0089-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch index 301e781..171bf82 100644 --- a/0115-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch +++ b/0089-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch @@ -22,7 +22,7 @@ Signed-off-by: Ken Lin 2 files changed, 56 insertions(+) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 85adc9cb447..2e46842e829 100644 +index 68c4df681b5..0b430489329 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -20,6 +20,7 @@ @@ -33,7 +33,7 @@ index 85adc9cb447..2e46842e829 100644 #include #include #include -@@ -567,6 +568,60 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -500,6 +501,60 @@ grub_net_configure_by_dhcp_ack (const char *name, if (opt && opt_len) grub_env_set_net_property (name, "rootpath", (const char *) opt, opt_len); @@ -95,14 +95,14 @@ index 85adc9cb447..2e46842e829 100644 if (opt && opt_len) grub_env_set_net_property (name, "extensionspath", (const char *) opt, opt_len); diff --git a/include/grub/net.h b/include/grub/net.h -index aedf4b59cfe..ebb569bd86e 100644 +index 543251f7273..42af7de250a 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -526,6 +526,7 @@ enum - GRUB_NET_BOOTP_DOMAIN = 0x0f, - GRUB_NET_BOOTP_ROOT_PATH = 0x11, - GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, -+ GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER = 0x3C, - GRUB_NET_BOOTP_CLIENT_ID = 0x3d, - GRUB_NET_BOOTP_CLIENT_UUID = 0x61, - GRUB_NET_DHCP_REQUESTED_IP_ADDRESS = 50, +@@ -531,6 +531,7 @@ enum + GRUB_NET_DHCP_MESSAGE_TYPE = 53, + GRUB_NET_DHCP_SERVER_IDENTIFIER = 54, + GRUB_NET_DHCP_PARAMETER_REQUEST_LIST = 55, ++ GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER = 60, + GRUB_NET_BOOTP_CLIENT_ID = 61, + GRUB_NET_DHCP_TFTP_SERVER_NAME = 66, + GRUB_NET_DHCP_BOOTFILE_NAME = 67, diff --git a/0089-editenv-handle-relative-symlinks.patch b/0089-editenv-handle-relative-symlinks.patch deleted file mode 100644 index 06adca7..0000000 --- a/0089-editenv-handle-relative-symlinks.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jonathan Lebon -Date: Mon, 14 Aug 2017 14:37:20 -0400 -Subject: [PATCH] editenv: handle relative symlinks - -Handle symlinks with targets relative to the containing dir. This -ensures that the rename operation does not depend on the cwd. - -Resolves: rhbz#1479960 - -Signed-off-by: Jonathan Lebon ---- - util/editenv.c | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -diff --git a/util/editenv.c b/util/editenv.c -index e61dc1283a4..1f7f6f3ae18 100644 ---- a/util/editenv.c -+++ b/util/editenv.c -@@ -28,6 +28,7 @@ - - #include - #include -+#include - - #define DEFAULT_ENVBLK_SIZE 1024 - -@@ -88,9 +89,20 @@ grub_util_create_envblk_file (const char *name) - continue; - } - -- free (rename_target); - linkbuf[retsize] = '\0'; -- rename_target = linkbuf; -+ if (linkbuf[0] == '/') -+ { -+ free (rename_target); -+ rename_target = linkbuf; -+ } -+ else -+ { -+ char *dbuf = xstrdup (rename_target); -+ const char *dir = dirname (dbuf); -+ free (rename_target); -+ rename_target = xasprintf("%s/%s", dir, linkbuf); -+ free (dbuf); -+ } - } - - int rc = grub_util_rename (namenew, rename_target); diff --git a/0090-Make-libgrub.pp-depend-on-config-util.h.patch b/0090-Make-libgrub.pp-depend-on-config-util.h.patch deleted file mode 100644 index 9a7d85f..0000000 --- a/0090-Make-libgrub.pp-depend-on-config-util.h.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 23 Aug 2017 10:37:27 -0400 -Subject: [PATCH] Make libgrub.pp depend on config-util.h - -If you build with "make -j48" a lot, sometimes you see: - -gcc -E -DHAVE_CONFIG_H -I. -I.. -Wall -W -DGRUB_UTIL=1 -D_FILE_OFFSET_BITS=64 -I./include -DGRUB_FILE=\"grub_script.tab.h\" -I. -I.. -I. -I.. -I../include -I./include -I../grub-core/lib/libgcrypt-grub/src/ -I../grub-core/lib/minilzo -I../grub-core/lib/xzembed -DMINILZO_HAVE_CONFIG_H -Wall -W -DGRUB_UTIL=1 -D_FILE_OFFSET_BITS=64 -I./include -DGRUB_FILE=\"grub_script.tab.h\" -I. -I.. -I. -I.. -I../include -I./include -I../grub-core/lib/libgcrypt-grub/src/ -I./grub-core/gnulib -I../grub-core/gnulib -I/builddir/build/BUILD/grub-2.02/grub-aarch64-efi-2.02 -D_FILE_OFFSET_BITS=64 \ - -D'GRUB_MOD_INIT(x)=@MARKER@x@' grub_script.tab.h grub_script.yy.h ../grub-core/commands/blocklist.c ../grub-core/commands/macbless.c ../grub-core/commands/xnu_uuid.c ../grub-core/commands/testload.c ../grub-core/commands/ls.c ../grub-core/disk/dmraid_nvidia.c ../grub-core/disk/loopback.c ../grub-core/disk/lvm.c ../grub-core/disk/mdraid_linux.c ../grub-core/disk/mdraid_linux_be.c ../grub-core/disk/mdraid1x_linux.c ../grub-core/disk/raid5_recover.c ../grub-core/disk/raid6_recover.c ../grub-core/font/font.c ../grub-core/gfxmenu/font.c ../grub-core/normal/charset.c ../grub-core/video/fb/fbblit.c ../grub-core/video/fb/fbutil.c ../grub-core/video/fb/fbfill.c ../grub-core/video/fb/video_fb.c ../grub-core/video/video.c ../grub-core/video/capture.c ../grub-core/video/colors.c ../grub-core/unidata.c ../grub-core/io/bufio.c ../grub-core/fs/affs.c ../grub-core/fs/afs.c ../grub-core/fs/bfs.c ../grub-core/fs/btrfs.c ../grub-core/fs/cbfs.c ../grub-core/fs/cpio.c ../grub-core/fs/cpio_be.c ../grub-core/fs/odc.c ../grub-core/fs/newc.c ../grub-core/fs/ext2.c ../grub-core/fs/fat.c ../grub-core/fs/exfat.c ../grub-core/fs/fshelp.c ../grub-core/fs/hfs.c ../grub-core/fs/hfsplus.c ../grub-core/fs/hfspluscomp.c ../grub-core/fs/iso9660.c ../grub-core/fs/jfs.c ../grub-core/fs/minix.c ../grub-core/fs/minix2.c ../grub-core/fs/minix3.c ../grub-core/fs/minix_be.c ../grub-core/fs/minix2_be.c ../grub-core/fs/minix3_be.c ../grub-core/fs/nilfs2.c ../grub-core/fs/ntfs.c ../grub-core/fs/ntfscomp.c ../grub-core/fs/reiserfs.c ../grub-core/fs/romfs.c ../grub-core/fs/sfs.c ../grub-core/fs/squash4.c ../grub-core/fs/tar.c ../grub-core/fs/udf.c ../grub-core/fs/ufs2.c ../grub-core/fs/ufs.c ../grub-core/fs/ufs_be.c ../grub-core/fs/xfs.c ../grub-core/fs/zfs/zfscrypt.c ../grub-core/fs/zfs/zfs.c ../grub-core/fs/zfs/zfsinfo.c ../grub-core/fs/zfs/zfs_lzjb.c ../grub-core/fs/zfs/zfs_lz4.c ../grub-core/fs/zfs/zfs_sha256.c ../grub-core/fs/zfs/zfs_fletcher.c ../grub-core/lib/envblk.c ../grub-core/lib/hexdump.c ../grub-core/lib/LzFind.c ../grub-core/lib/LzmaEnc.c ../grub-core/lib/crc.c ../grub-core/lib/adler32.c ../grub-core/lib/crc64.c ../grub-core/normal/datetime.c ../grub-core/normal/misc.c ../grub-core/partmap/acorn.c ../grub-core/partmap/amiga.c ../grub-core/partmap/apple.c ../grub-core/partmap/sun.c ../grub-core/partmap/plan.c ../grub-core/partmap/dvh.c ../grub-core/partmap/sunpc.c ../grub-core/partmap/bsdlabel.c ../grub-core/partmap/dfly.c ../grub-core/script/function.c ../grub-core/script/lexer.c ../grub-core/script/main.c ../grub-core/script/script.c ../grub-core/script/argv.c ../grub-core/io/gzio.c ../grub-core/io/xzio.c ../grub-core/io/lzopio.c ../grub-core/kern/ia64/dl_helper.c ../grub-core/kern/arm/dl_helper.c ../grub-core/kern/arm64/dl_helper.c ../grub-core/lib/minilzo/minilzo.c ../grub-core/lib/xzembed/xz_dec_bcj.c ../grub-core/lib/xzembed/xz_dec_lzma2.c ../grub-core/lib/xzembed/xz_dec_stream.c ../util/misc.c ../grub-core/kern/command.c ../grub-core/kern/device.c ../grub-core/kern/disk.c ../grub-core/lib/disk.c ../util/getroot.c ../grub-core/osdep/unix/getroot.c ../grub-core/osdep/getroot.c ../grub-core/osdep/devmapper/getroot.c ../grub-core/osdep/relpath.c ../grub-core/kern/emu/hostdisk.c ../grub-core/osdep/devmapper/hostdisk.c ../grub-core/osdep/hostdisk.c ../grub-core/osdep/unix/hostdisk.c ../grub-core/osdep/exec.c ../grub-core/osdep/sleep.c ../grub-core/osdep/password.c ../grub-core/kern/emu/misc.c ../grub-core/kern/emu/mm.c ../grub-core/kern/env.c ../grub-core/kern/err.c ../grub-core/kern/file.c ../grub-core/kern/fs.c ../grub-core/kern/list.c ../grub-core/kern/misc.c ../grub-core/kern/partition.c ../grub-core/lib/crypto.c ../grub-core/disk/luks.c ../grub-core/disk/geli.c ../grub-core/disk/cryptodisk.c ../grub-core/disk/AFSplitter.c ../grub-core/lib/pbkdf2.c ../grub-core/commands/extcmd.c ../grub-core/lib/arg.c ../grub-core/disk/ldm.c ../grub-core/disk/diskfilter.c ../grub-core/partmap/gpt.c ../grub-core/partmap/msdos.c ../grub-core/fs/proc.c ../grub-core/fs/archelp.c > libgrub.pp || (rm -f libgrub.pp; exit 1) -rm -f stamp-h1 -touch ../config-util.h.in -cd . && /bin/sh ./config.status config-util.h -config.status: creating config-util.h -In file included from ../include/grub/mm.h:25:0, - from ../include/grub/disk.h:29, - from ../include/grub/file.h:26, - from ../grub-core/fs/btrfs.c:21: -./config.h:38:10: fatal error: ./config-util.h: No such file or directory - #include - ^~~~~~~~~~~~~~~ -compilation terminated. -make: *** [Makefile:13098: libgrub.pp] Error 1 - -This is because libgrub.pp is built with -DGRUB_UTIL=1, which means -it'll try to include config-util.h, but a parallel make is actually -building that file. I think. - -Signed-off-by: Peter Jones ---- - Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile.am b/Makefile.am -index 1f4bb9b8c5a..bf9c1ba64c9 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -37,7 +37,7 @@ grub_script.yy.c: grub_script.yy.h - CLEANFILES += grub_script.yy.c grub_script.yy.h - - # For libgrub.a --libgrub.pp: grub_script.tab.h grub_script.yy.h $(libgrubmods_a_SOURCES) $(libgrubkern_a_SOURCES) -+libgrub.pp: config-util.h grub_script.tab.h grub_script.yy.h $(libgrubmods_a_SOURCES) $(libgrubkern_a_SOURCES) - $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgrubmods_a_CPPFLAGS) $(libgrubkern_a_CPPFLAGS) $(CPPFLAGS) \ - -D'GRUB_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1) - CLEANFILES += libgrub.pp diff --git a/0116-efinet-Setting-network-from-UEFI-device-path.patch b/0090-efinet-Setting-network-from-UEFI-device-path.patch similarity index 95% rename from 0116-efinet-Setting-network-from-UEFI-device-path.patch rename to 0090-efinet-Setting-network-from-UEFI-device-path.patch index f017295..11b2a72 100644 --- a/0116-efinet-Setting-network-from-UEFI-device-path.patch +++ b/0090-efinet-Setting-network-from-UEFI-device-path.patch @@ -32,10 +32,10 @@ Signed-off-by: Ken Lin 2 files changed, 280 insertions(+), 15 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index c3db3285b97..2817b6f8fb9 100644 +index 014e5bf9802..8171ecaa5e4 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -27,6 +27,7 @@ +@@ -26,6 +26,7 @@ #include #include #include @@ -43,7 +43,7 @@ index c3db3285b97..2817b6f8fb9 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -332,6 +333,227 @@ grub_efinet_findcards (void) +@@ -331,6 +332,227 @@ grub_efinet_findcards (void) grub_free (handles); } @@ -271,7 +271,7 @@ index c3db3285b97..2817b6f8fb9 100644 static void grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, char **path) -@@ -347,7 +569,11 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -346,7 +568,11 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, { grub_efi_device_path_t *cdp; struct grub_efi_pxe *pxe; @@ -284,7 +284,7 @@ index c3db3285b97..2817b6f8fb9 100644 if (card->driver != &efidriver) continue; -@@ -371,11 +597,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -370,11 +596,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, */ if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE @@ -307,7 +307,7 @@ index c3db3285b97..2817b6f8fb9 100644 dup_ldp = grub_efi_find_last_device_path (dup_dp); dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; -@@ -388,23 +624,37 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -387,23 +623,37 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, pxe = grub_efi_open_protocol (hnd, &pxe_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); @@ -356,7 +356,7 @@ index c3db3285b97..2817b6f8fb9 100644 1, device, path); if (grub_errno) grub_print_error (); -@@ -418,11 +668,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -417,11 +667,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, grub_dprintf ("efinet", "using ipv4 and dhcp\n"); grub_net_configure_by_dhcp_ack (card->name, card, 0, (struct grub_net_bootp_packet *) @@ -375,10 +375,10 @@ index c3db3285b97..2817b6f8fb9 100644 } } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 186cf398840..0d4839a41f1 100644 +index 91ab528e4d0..4a51667adb1 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -839,6 +839,8 @@ struct grub_efi_ipv4_device_path +@@ -864,6 +864,8 @@ struct grub_efi_ipv4_device_path grub_efi_uint16_t remote_port; grub_efi_uint16_t protocol; grub_efi_uint8_t static_ip_address; @@ -387,7 +387,7 @@ index 186cf398840..0d4839a41f1 100644 } GRUB_PACKED; typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t; -@@ -893,6 +895,15 @@ struct grub_efi_sata_device_path +@@ -918,6 +920,15 @@ struct grub_efi_sata_device_path } GRUB_PACKED; typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t; diff --git a/0117-efinet-Setting-DNS-server-from-UEFI-protocol.patch b/0091-efinet-Setting-DNS-server-from-UEFI-protocol.patch similarity index 92% rename from 0117-efinet-Setting-DNS-server-from-UEFI-protocol.patch rename to 0091-efinet-Setting-DNS-server-from-UEFI-protocol.patch index d79b34a..1460c8a 100644 --- a/0117-efinet-Setting-DNS-server-from-UEFI-protocol.patch +++ b/0091-efinet-Setting-DNS-server-from-UEFI-protocol.patch @@ -29,14 +29,14 @@ Signed-off-by: Michael Chang Signed-off-by: Ken Lin --- grub-core/net/drivers/efi/efinet.c | 163 +++++++++++++++++++++++++++++++++++++ - include/grub/efi/api.h | 76 +++++++++++++++++ - 2 files changed, 239 insertions(+) + include/grub/efi/api.h | 75 +++++++++++++++++ + 2 files changed, 238 insertions(+) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 2817b6f8fb9..c843654b830 100644 +index 8171ecaa5e4..715a6168d77 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -34,6 +34,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); +@@ -33,6 +33,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); /* GUID. */ static grub_efi_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID; static grub_efi_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID; @@ -45,7 +45,7 @@ index 2817b6f8fb9..c843654b830 100644 static grub_err_t send_card_buffer (struct grub_net_card *dev, -@@ -333,6 +335,125 @@ grub_efinet_findcards (void) +@@ -332,6 +334,125 @@ grub_efinet_findcards (void) grub_free (handles); } @@ -171,7 +171,7 @@ index 2817b6f8fb9..c843654b830 100644 static struct grub_net_buff * grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *use_ipv6) { -@@ -391,6 +512,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -390,6 +511,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u grub_efi_ipv4_device_path_t *ipv4 = (grub_efi_ipv4_device_path_t *) ldp; struct grub_net_bootp_packet *bp; grub_uint8_t *ptr; @@ -180,7 +180,7 @@ index 2817b6f8fb9..c843654b830 100644 bp = (struct grub_net_bootp_packet *) nb->tail; err = grub_netbuff_put (nb, sizeof (*bp) + 4); -@@ -452,6 +575,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -451,6 +574,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u *ptr++ = sizeof ("HTTPClient") - 1; grub_memcpy (ptr, "HTTPClient", sizeof ("HTTPClient") - 1); @@ -206,7 +206,7 @@ index 2817b6f8fb9..c843654b830 100644 ptr = nb->tail; err = grub_netbuff_put (nb, 1); if (err) -@@ -484,6 +626,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -483,6 +625,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u struct grub_net_dhcp6_option *opt; struct grub_net_dhcp6_option_iana *iana; struct grub_net_dhcp6_option_iaaddr *iaaddr; @@ -215,7 +215,7 @@ index 2817b6f8fb9..c843654b830 100644 d6p = (struct grub_net_dhcp6_packet *)nb->tail; err = grub_netbuff_put (nb, sizeof(*d6p)); -@@ -547,6 +691,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -546,6 +690,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u opt->len = grub_cpu_to_be16 (uri_len); grub_memcpy (opt->data, uri_dp->uri, uri_len); @@ -242,13 +242,14 @@ index 2817b6f8fb9..c843654b830 100644 } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 0d4839a41f1..716f121728b 100644 +index 4a51667adb1..0b490195ad9 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -334,6 +334,16 @@ - { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \ - } - +@@ -352,6 +352,15 @@ + #define GRUB_EFI_RNG_PROTOCOL_GUID \ + { 0x3152bca5, 0xeade, 0x433d, \ + { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \ ++ +#define GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID \ + { 0x5b446ed1, 0xe30b, 0x4faa, \ + { 0x87, 0x1a, 0x36, 0x54, 0xec, 0xa3, 0x60, 0x80 } \ @@ -257,14 +258,12 @@ index 0d4839a41f1..716f121728b 100644 +#define GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID \ + { 0x937fe521, 0x95ae, 0x4d1a, \ + { 0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a } \ -+ } -+ + } + struct grub_efi_sal_system_table - { - grub_uint32_t signature; -@@ -1838,6 +1848,72 @@ struct grub_efi_block_io +@@ -1883,6 +1892,72 @@ struct grub_efi_rng_protocol }; - typedef struct grub_efi_block_io grub_efi_block_io_t; + typedef struct grub_efi_rng_protocol grub_efi_rng_protocol_t; +enum grub_efi_ip4_config2_data_type { + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO, diff --git a/0119-Support-UEFI-networking-protocols.patch b/0092-Support-UEFI-networking-protocols.patch similarity index 99% rename from 0119-Support-UEFI-networking-protocols.patch rename to 0092-Support-UEFI-networking-protocols.patch index 3b0ff4a..e69054f 100644 --- a/0119-Support-UEFI-networking-protocols.patch +++ b/0092-Support-UEFI-networking-protocols.patch @@ -57,10 +57,10 @@ Signed-off-by: Peter Jones create mode 100644 include/grub/net/efi.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 49c5dc4c3b7..48491b50683 100644 +index 4b7c45a7b06..c40170f2dd2 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2276,6 +2276,12 @@ module = { +@@ -2299,6 +2299,12 @@ module = { common = hook/datehook.c; }; @@ -73,10 +73,10 @@ index 49c5dc4c3b7..48491b50683 100644 module = { name = net; common = net/net.c; -@@ -2290,6 +2296,12 @@ module = { +@@ -2312,6 +2318,12 @@ module = { + common = net/ethernet.c; common = net/arp.c; common = net/netbuff.c; - common = net/url.c; + efi = net/efi/net.c; + efi = net/efi/http.c; + efi = net/efi/pxe.c; @@ -100,10 +100,10 @@ index a458c3aca78..1637731535e 100644 if (file->offset + res < next_buf) { diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 19054b1465f..ada3004cfba 100644 +index d6a2fb57789..2a446f5031b 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -709,7 +709,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -755,7 +755,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) { grub_efi_ipv4_device_path_t *ipv4 = (grub_efi_ipv4_device_path_t *) dp; @@ -112,7 +112,7 @@ index 19054b1465f..ada3004cfba 100644 (unsigned) ipv4->local_ip_address[0], (unsigned) ipv4->local_ip_address[1], (unsigned) ipv4->local_ip_address[2], -@@ -722,33 +722,60 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -768,33 +768,60 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) (unsigned) ipv4->remote_port, (unsigned) ipv4->protocol, (unsigned) ipv4->static_ip_address); @@ -190,7 +190,7 @@ index 19054b1465f..ada3004cfba 100644 } break; case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE: -@@ -788,6 +815,39 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -834,6 +861,39 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) dump_vendor_path ("Messaging", (grub_efi_vendor_device_path_t *) dp); break; @@ -231,10 +231,10 @@ index 19054b1465f..ada3004cfba 100644 grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype); break; diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index c843654b830..ca8bd3c2301 100644 +index 715a6168d77..e11d759f19a 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -28,6 +28,7 @@ +@@ -27,6 +27,7 @@ #include #include #include @@ -242,7 +242,7 @@ index c843654b830..ca8bd3c2301 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -492,6 +493,17 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -491,6 +492,17 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u ldp = grub_efi_find_last_device_path (ddp); @@ -260,7 +260,7 @@ index c843654b830..ca8bd3c2301 100644 if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) -@@ -761,6 +773,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -760,6 +772,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE @@ -268,7 +268,7 @@ index c843654b830..ca8bd3c2301 100644 && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_URI_DEVICE_PATH_SUBTYPE)) continue; dup_dp = grub_efi_duplicate_device_path (dp); -@@ -775,6 +788,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -774,6 +787,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, dup_ldp->length = sizeof (*dup_ldp); } @@ -284,7 +284,7 @@ index c843654b830..ca8bd3c2301 100644 dup_ldp = grub_efi_find_last_device_path (dup_dp); dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; -@@ -846,6 +868,9 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -845,6 +867,9 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, GRUB_MOD_INIT(efinet) { @@ -294,7 +294,7 @@ index c843654b830..ca8bd3c2301 100644 grub_efinet_findcards (); grub_efi_net_config = grub_efi_net_config_real; } -@@ -857,5 +882,7 @@ GRUB_MOD_FINI(efinet) +@@ -856,5 +881,7 @@ GRUB_MOD_FINI(efinet) FOR_NET_CARDS_SAFE (card, next) if (card->driver == &efidriver) grub_net_card_unregister (card); @@ -3890,7 +3890,7 @@ index 00000000000..531949cba5c + }; + diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 2734f70d22f..27a0a1d6961 100644 +index 0ce5e675ed7..55aed92722c 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -32,6 +32,9 @@ @@ -3903,7 +3903,7 @@ index 2734f70d22f..27a0a1d6961 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -2025,8 +2028,49 @@ static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute; +@@ -2033,8 +2036,49 @@ static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute; static grub_command_t cmd_lsroutes, cmd_lscards; static grub_command_t cmd_lsaddr, cmd_slaac; @@ -3953,7 +3953,7 @@ index 2734f70d22f..27a0a1d6961 100644 grub_register_variable_hook ("net_default_server", defserver_get_env, defserver_set_env); grub_env_export ("net_default_server"); -@@ -2074,10 +2118,37 @@ GRUB_MOD_INIT(net) +@@ -2082,10 +2126,37 @@ GRUB_MOD_INIT(net) grub_net_restore_hw, GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK); grub_net_poll_cards_idle = grub_net_poll_cards_idle_real; @@ -3991,7 +3991,7 @@ index 2734f70d22f..27a0a1d6961 100644 grub_register_variable_hook ("net_default_server", 0, 0); grub_register_variable_hook ("pxe_default_server", 0, 0); -@@ -2096,4 +2167,7 @@ GRUB_MOD_FINI(net) +@@ -2104,4 +2175,7 @@ GRUB_MOD_FINI(net) grub_net_fini_hw (0); grub_loader_unregister_preboot_hook (fini_hnd); grub_net_poll_cards_idle = grub_net_poll_cards_idle_real; @@ -4082,10 +4082,10 @@ index 602574d52e8..1a61e05c6ec 100644 if (!grub_install_source_directory) { diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 716f121728b..2ed9c26a450 100644 +index 0b490195ad9..f431f49973e 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -602,6 +602,23 @@ typedef union +@@ -622,6 +622,23 @@ typedef union typedef grub_efi_uint64_t grub_efi_physical_address_t; typedef grub_efi_uint64_t grub_efi_virtual_address_t; @@ -4109,7 +4109,7 @@ index 716f121728b..2ed9c26a450 100644 struct grub_efi_guid { -@@ -865,6 +882,8 @@ struct grub_efi_ipv6_device_path +@@ -889,6 +906,8 @@ struct grub_efi_ipv6_device_path grub_efi_uint16_t remote_port; grub_efi_uint16_t protocol; grub_efi_uint8_t static_ip_address; @@ -4118,7 +4118,7 @@ index 716f121728b..2ed9c26a450 100644 } GRUB_PACKED; typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t; -@@ -914,6 +933,15 @@ struct grub_efi_uri_device_path +@@ -938,6 +957,15 @@ struct grub_efi_uri_device_path } GRUB_PACKED; typedef struct grub_efi_uri_device_path grub_efi_uri_device_path_t; @@ -4134,7 +4134,7 @@ index 716f121728b..2ed9c26a450 100644 #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10 /* Media Device Path. */ -@@ -996,6 +1024,23 @@ struct grub_efi_bios_device_path +@@ -1020,6 +1048,23 @@ struct grub_efi_bios_device_path } GRUB_PACKED; typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t; @@ -4158,7 +4158,7 @@ index 716f121728b..2ed9c26a450 100644 struct grub_efi_open_protocol_information_entry { grub_efi_handle_t agent_handle; -@@ -1545,23 +1590,27 @@ typedef struct grub_efi_pxe_tftp_error +@@ -1569,23 +1614,27 @@ typedef struct grub_efi_pxe_tftp_error grub_efi_char8_t error_string[127]; } grub_efi_pxe_tftp_error_t; @@ -4200,7 +4200,7 @@ index 716f121728b..2ed9c26a450 100644 #define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8 typedef struct grub_efi_pxe_ip_filter -@@ -1628,17 +1677,31 @@ typedef struct grub_efi_pxe_mode +@@ -1652,17 +1701,31 @@ typedef struct grub_efi_pxe_mode typedef struct grub_efi_pxe { grub_uint64_t rev; @@ -4236,7 +4236,7 @@ index 716f121728b..2ed9c26a450 100644 void (*setpackets) (void); struct grub_efi_pxe_mode *mode; } grub_efi_pxe_t; -@@ -1880,6 +1943,44 @@ struct grub_efi_ip4_config2_protocol +@@ -1924,6 +1987,44 @@ struct grub_efi_ip4_config2_protocol }; typedef struct grub_efi_ip4_config2_protocol grub_efi_ip4_config2_protocol_t; @@ -4281,7 +4281,7 @@ index 716f121728b..2ed9c26a450 100644 enum grub_efi_ip6_config_data_type { GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO, GRUB_EFI_IP6_CONFIG_DATA_TYPE_ALT_INTERFACEID, -@@ -1914,6 +2015,49 @@ struct grub_efi_ip6_config_protocol +@@ -1958,6 +2059,49 @@ struct grub_efi_ip6_config_protocol }; typedef struct grub_efi_ip6_config_protocol grub_efi_ip6_config_protocol_t; diff --git a/0120-AUDIT-0-http-boot-tracker-bug.patch b/0093-AUDIT-0-http-boot-tracker-bug.patch similarity index 98% rename from 0120-AUDIT-0-http-boot-tracker-bug.patch rename to 0093-AUDIT-0-http-boot-tracker-bug.patch index 78a78e4..ef3e67b 100644 --- a/0120-AUDIT-0-http-boot-tracker-bug.patch +++ b/0093-AUDIT-0-http-boot-tracker-bug.patch @@ -38,7 +38,7 @@ index 86bce6535d3..4bb308026ce 100644 if (buf) { diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 00737c52750..c9c59690a98 100644 +index 12a2632ea55..b52b558d631 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -31,7 +31,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/0128-grub-editenv-Add-incr-command-to-increment-integer-v.patch b/0094-grub-editenv-Add-incr-command-to-increment-integer-v.patch similarity index 94% rename from 0128-grub-editenv-Add-incr-command-to-increment-integer-v.patch rename to 0094-grub-editenv-Add-incr-command-to-increment-integer-v.patch index 5da986f..f8de42a 100644 --- a/0128-grub-editenv-Add-incr-command-to-increment-integer-v.patch +++ b/0094-grub-editenv-Add-incr-command-to-increment-integer-v.patch @@ -17,7 +17,7 @@ Signed-off-by: Hans de Goede 1 file changed, 50 insertions(+) diff --git a/util/grub-editenv.c b/util/grub-editenv.c -index f3662c95ba6..d848038abea 100644 +index db6f187cc63..948eec8a114 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -53,6 +53,9 @@ static struct argp_option options[] = { @@ -30,7 +30,7 @@ index f3662c95ba6..d848038abea 100644 {0, 0, 0, OPTION_DOC, N_("Options:"), -1}, {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, -@@ -247,6 +250,51 @@ unset_variables (const char *name, int argc, char *argv[]) +@@ -253,6 +256,51 @@ unset_variables (const char *name, int argc, char *argv[]) grub_envblk_close (envblk); } @@ -82,7 +82,7 @@ index f3662c95ba6..d848038abea 100644 int main (int argc, char *argv[]) { -@@ -286,6 +334,8 @@ main (int argc, char *argv[]) +@@ -292,6 +340,8 @@ main (int argc, char *argv[]) set_variables (filename, argc - curindex, argv + curindex); else if (strcmp (command, "unset") == 0) unset_variables (filename, argc - curindex, argv + curindex); diff --git a/0095-Add-BLS-support-to-grub-mkconfig.patch b/0095-Add-BLS-support-to-grub-mkconfig.patch deleted file mode 100644 index 70277ef..0000000 --- a/0095-Add-BLS-support-to-grub-mkconfig.patch +++ /dev/null @@ -1,741 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 9 Dec 2016 15:40:29 -0500 -Subject: [PATCH] Add BLS support to grub-mkconfig - -GRUB now has BootLoaderSpec support, the user can choose to use this by -setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup, -the boot menu entries are not added to the grub.cfg, instead BLS config -files are parsed by blscfg command and the entries created dynamically. - -A 10_linux_bls grub.d snippet to generate menu entries from BLS files -is also added that can be used on platforms where the bootloader doesn't -have BLS support and only can parse a normal grub configuration file. - -Portions of the 10_linux_bls were taken from the ostree-grub-generator -script that's included in the OSTree project. - -Fixes to support multi-devices and generate a BLS section even if no -kernels are found in the boot directory were proposed by Yclept Nemo -and Tom Gundersen respectively. - -Signed-off-by: Peter Jones -Signed-off-by: Javier Martinez Canillas ---- - Makefile.util.def | 7 + - util/grub-mkconfig.8 | 4 + - util/grub-mkconfig.in | 9 +- - util/grub-mkconfig_lib.in | 20 +- - util/grub.d/10_linux.in | 67 ++++++- - util/grub.d/10_linux_bls.in | 478 ++++++++++++++++++++++++++++++++++++++++++++ - 6 files changed, 580 insertions(+), 5 deletions(-) - create mode 100644 util/grub.d/10_linux_bls.in - -diff --git a/Makefile.util.def b/Makefile.util.def -index 2215cc759c0..a61613656d1 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -499,6 +499,13 @@ script = { - condition = COND_HOST_LINUX; - }; - -+script = { -+ name = '10_linux_bls'; -+ common = util/grub.d/10_linux_bls.in; -+ installdir = grubconf; -+ condition = COND_HOST_LINUX; -+}; -+ - script = { - name = '10_xnu'; - common = util/grub.d/10_xnu.in; -diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8 -index a2d1f577b9b..434fa4deda4 100644 ---- a/util/grub-mkconfig.8 -+++ b/util/grub-mkconfig.8 -@@ -13,5 +13,9 @@ - \fB--output\fR=\fIFILE\fR - Write generated output to \fIFILE\fR. - -+.TP -+\fB--no-grubenv-update\fR -+Do not update variables in the grubenv file. -+ - .SH SEE ALSO - .BR "info grub" -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 4649e92eb0f..2601bdc0711 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" - export TEXTDOMAIN=@PACKAGE@ - export TEXTDOMAINDIR="@localedir@" - -+export GRUB_GRUBENV_UPDATE="yes" -+ - . "${pkgdatadir}/grub-mkconfig_lib" - - # Usage: usage -@@ -59,6 +61,7 @@ usage () { - gettext "Generate a grub config file"; echo - echo - print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")" -+ print_option_help "--no-grubenv-update" "$(gettext "do not update variables in the grubenv file")" - print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" - echo -@@ -94,6 +97,9 @@ do - --output=*) - grub_cfg=`echo "$option" | sed 's/--output=//'` - ;; -+ --no-grubenv-update) -+ GRUB_GRUBENV_UPDATE="no" -+ ;; - -*) - gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 - usage -@@ -259,7 +265,8 @@ export GRUB_DEFAULT \ - GRUB_OS_PROBER_SKIP_LIST \ - GRUB_DISABLE_SUBMENU \ - GRUB_DEFAULT_DTB \ -- SUSE_BTRFS_SNAPSHOT_BOOTING -+ SUSE_BTRFS_SNAPSHOT_BOOTING \ -+ GRUB_ENABLE_BLSCFG - - if test "x${grub_cfg}" != "x"; then - rm -f "${grub_cfg}.new" -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index b3aae534ddc..bc11df2bd84 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -30,6 +30,9 @@ fi - if test "x$grub_file" = x; then - grub_file="${bindir}/@grub_file@" - fi -+if test "x$grub_editenv" = x; then -+ grub_editenv="${bindir}/@grub_editenv@" -+fi - if test "x$grub_mkrelpath" = x; then - grub_mkrelpath="${bindir}/@grub_mkrelpath@" - fi -@@ -125,8 +128,19 @@ EOF - fi - } - -+prepare_grub_to_access_device_with_variable () -+{ -+ device_variable="$1" -+ shift -+ prepare_grub_to_access_device "$@" -+ unset "device_variable" -+} -+ - prepare_grub_to_access_device () - { -+ if [ -z "$device_variable" ]; then -+ device_variable="root" -+ fi - old_ifs="$IFS" - IFS=' - ' -@@ -161,14 +175,14 @@ prepare_grub_to_access_device () - # otherwise set root as per value in device.map. - fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`" - if [ "x$fs_hint" != x ]; then -- echo "set root='$fs_hint'" -+ echo "set ${device_variable}='$fs_hint'" - fi - if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then - hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= - echo "if [ x\$feature_platform_search_hint = xy ]; then" -- echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" -+ echo " search --no-floppy --fs-uuid --set=${device_variable} ${hints} ${fs_uuid}" - echo "else" -- echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}" -+ echo " search --no-floppy --fs-uuid --set=${device_variable} ${fs_uuid}" - echo "fi" - fi - IFS="$old_ifs" -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 5cab299dc08..301594a0c9e 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -82,6 +82,67 @@ case x"$GRUB_FS" in - ;; - esac - -+populate_header_warn() -+{ -+cat <$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then -@@ -224,6 +286,7 @@ is_top_level=true - while [ "x$list" != "x" ] ; do - linux=`version_find_latest $list` - gettext_printf "Found linux image: %s\n" "$linux" >&2 -+ - basename=`basename $linux` - dirname=`dirname $linux` - rel_dirname=`make_system_path_relative_to_its_root $dirname` -@@ -262,7 +325,9 @@ while [ "x$list" != "x" ] ; do - for i in ${initrd}; do - initrd_display="${initrd_display} ${dirname}/${i}" - done -- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 -+ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -+ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 -+ fi - fi - - fdt= -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -new file mode 100644 -index 00000000000..1b7536435f1 ---- /dev/null -+++ b/util/grub.d/10_linux_bls.in -@@ -0,0 +1,478 @@ -+#! /bin/sh -+set -e -+ -+# grub-mkconfig helper script. -+# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. -+# -+# GRUB is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 3 of the License, or -+# (at your option) any later version. -+# -+# GRUB is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with GRUB. If not, see . -+ -+prefix="@prefix@" -+exec_prefix="@exec_prefix@" -+datarootdir="@datarootdir@" -+ -+. "$pkgdatadir/grub-mkconfig_lib" -+ -+export TEXTDOMAIN=@PACKAGE@ -+export TEXTDOMAINDIR="@localedir@" -+ -+CLASS="--class gnu-linux --class gnu --class os --unrestricted" -+ -+if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then -+ OS="$(eval $(grep PRETTY_NAME /etc/os-release) ; echo ${PRETTY_NAME})" -+ CLASS="--class $(eval $(grep '^ID_LIKE=\|^ID=' /etc/os-release) ; [ -n "${ID_LIKE}" ] && echo ${ID_LIKE} || echo ${ID}) ${CLASS}" -+else -+ OS="${GRUB_DISTRIBUTOR}" -+ CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" -+fi -+ -+# loop-AES arranges things so that /dev/loop/X can be our root device, but -+# the initrds that Linux uses don't like that. -+case ${GRUB_DEVICE} in -+ /dev/loop/*|/dev/loop[0-9]) -+ GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` -+ ;; -+esac -+ -+# Default to disabling partition uuid support to maintian compatibility with -+# older kernels. -+GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} -+ -+# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter -+# and mounting btrfs requires user space scanning, so force UUID in this case. -+if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ -+ || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ -+ && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ -+ || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ -+ && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ -+ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then -+ LINUX_ROOT_DEVICE=${GRUB_DEVICE} -+elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ -+ || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then -+ LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} -+else -+ LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} -+fi -+ -+case x"$GRUB_FS" in -+ xbtrfs) -+ if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then -+ GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}" -+ else -+ rootsubvol="`make_system_path_relative_to_its_root /`" -+ rootsubvol="${rootsubvol#/}" -+ if [ "x${rootsubvol}" != x ]; then -+ GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" -+ fi -+ fi;; -+ xzfs) -+ rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` -+ bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" -+ LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" -+ ;; -+esac -+ -+mktitle () -+{ -+ local title_type -+ local version -+ local OS_NAME -+ local OS_VERS -+ -+ title_type=$1 && shift -+ version=$1 && shift -+ -+ OS_NAME="$(eval $(grep ^NAME= /etc/os-release) ; echo ${NAME})" -+ OS_VERS="$(eval $(grep ^VERSION= /etc/os-release) ; echo ${VERSION})" -+ -+ case $title_type in -+ recovery) -+ title=$(printf '%s (%s) %s (recovery mode)' \ -+ "${OS_NAME}" "${version}" "${OS_VERS}") -+ ;; -+ *) -+ title=$(printf '%s (%s) %s' \ -+ "${OS_NAME}" "${version}" "${OS_VERS}") -+ ;; -+ esac -+ echo -n ${title} -+} -+ -+title_correction_code= -+ -+populate_header_warn() -+{ -+cat <&2 -+ -+ files=($(for bls in ${blsdir}/*.conf ; do -+ if ! [[ -e "${bls}" ]] ; then -+ continue -+ fi -+ bls="${bls%.conf}" -+ bls="${bls##*/}" -+ echo "${bls}" -+ done | ${kernel_sort} | tac)) || : -+ -+ for bls in "${files[@]}" ; do -+ read_config "${blsdir}/${bls}.conf" -+ -+ menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id=${bls} {\n" -+ menu="${menu}\t linux ${linux} ${options}\n" -+ if [ -n "${initrd}" ] ; then -+ menu="${menu}\t initrd ${boot_prefix}${initrd}\n" -+ fi -+ menu="${menu}}\n\n" -+ done -+ # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation -+ printf "$menu" -+} -+ -+linux_entry () -+{ -+ os="$1" -+ version="$2" -+ type="$3" -+ isdebug="$4" -+ args="$5" -+ -+ if [ -z "$boot_device_id" ]; then -+ boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -+ fi -+ -+ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -+ if [ x$dirname = x/ ]; then -+ if [ -z "${prepare_root_cache}" ]; then -+ prepare_grub_to_access_device ${GRUB_DEVICE} -+ fi -+ else -+ if [ -z "${prepare_boot_cache}" ]; then -+ prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} -+ fi -+ fi -+ -+ if [ -d /sys/firmware/efi ]; then -+ bootefi_device="`${grub_probe} --target=device /boot/efi/`" -+ prepare_grub_to_access_device_with_variable boot ${bootefi_device} -+ else -+ boot_device="`${grub_probe} --target=device /boot/`" -+ prepare_grub_to_access_device_with_variable boot ${boot_device} -+ fi -+ -+ populate_header_warn -+ populate_menu -+ -+ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then -+ blsdir="/boot/loader/entries" -+ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})" -+ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then -+ blsdir=$(make_system_path_relative_to_its_root "${blsdir}") -+ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then -+ ${grub_editenv} - set blsdir="${blsdir}" -+ fi -+ fi -+ -+ ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" -+ if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then -+ ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" -+ fi -+ fi -+ -+ exit 0 -+ fi -+ -+ if [ x$type != xsimple ] ; then -+ title=$(mktitle "$type" "$version") -+ if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then -+ replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" -+ quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" -+ title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" -+ fi -+ if [ x$isdebug = xdebug ]; then -+ title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}" -+ fi -+ echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -+ else -+ echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -+ fi -+ if [ x$type != xrecovery ] ; then -+ save_default_entry | grub_add_tab -+ fi -+ -+ # Use ELILO's generic "efifb" when it's known to be available. -+ # FIXME: We need an interface to select vesafb in case efifb can't be used. -+ if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then -+ echo " load_video" | sed "s/^/$submenu_indentation/" -+ if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \ -+ && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then -+ echo " set gfxpayload=keep" | sed "s/^/$submenu_indentation/" -+ fi -+ else -+ if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then -+ echo " load_video" | sed "s/^/$submenu_indentation/" -+ fi -+ echo " set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/" -+ fi -+ -+ echo " insmod gzio" | sed "s/^/$submenu_indentation/" -+ -+ if [ x$dirname = x/ ]; then -+ if [ -z "${prepare_root_cache}" ]; then -+ prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)" -+ fi -+ printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/" -+ else -+ if [ -z "${prepare_boot_cache}" ]; then -+ prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)" -+ fi -+ printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" -+ fi -+ sed "s/^/$submenu_indentation/" << EOF -+ linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} -+EOF -+ if test -n "${initrd}" ; then -+ initrd_path= -+ for i in ${initrd}; do -+ initrd_path="${initrd_path} ${rel_dirname}/${i}" -+ done -+ sed "s/^/$submenu_indentation/" << EOF -+ initrd $(echo $initrd_path) -+EOF -+ fi -+ if test -n "${fdt}" ; then -+ sed "s/^/$submenu_indentation/" << EOF -+ devicetree ${rel_dirname}/${fdt} -+EOF -+ fi -+ sed "s/^/$submenu_indentation/" << EOF -+} -+EOF -+} -+ -+machine=`uname -m` -+case "x$machine" in -+ xi?86 | xx86_64) -+ list= -+ for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do -+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -+ done ;; -+ *) -+ list= -+ for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do -+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -+ done ;; -+esac -+ -+if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -+ for i in /boot/ostree/*/vmlinuz-* ; do -+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -+ done -+fi -+ -+case "$machine" in -+ i?86) GENKERNEL_ARCH="x86" ;; -+ mips|mips64) GENKERNEL_ARCH="mips" ;; -+ mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;; -+ arm*) GENKERNEL_ARCH="arm" ;; -+ *) GENKERNEL_ARCH="$machine" ;; -+esac -+ -+prepare_boot_cache= -+prepare_root_cache= -+boot_device_id= -+title_correction_code= -+ -+# Extra indentation to add to menu entries in a submenu. We're not in a submenu -+# yet, so it's empty. In a submenu it will be equal to '\t' (one tab). -+submenu_indentation="" -+ -+is_top_level=true -+while [ "x$list" != "x" ] ; do -+ linux=`version_find_latest $list` -+ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -+ gettext_printf "Found linux image: %s\n" "$linux" >&2 -+ fi -+ -+ basename=`basename $linux` -+ dirname=`dirname $linux` -+ rel_dirname=`make_system_path_relative_to_its_root $dirname` -+ version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` -+ alt_version=`echo $version | sed -e "s,\.old$,,g"` -+ linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" -+ -+ initrd_early= -+ for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \ -+ ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do -+ if test -e "${dirname}/${i}" ; then -+ initrd_early="${initrd_early} ${i}" -+ fi -+ done -+ -+ initrd_real= -+ for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \ -+ "initrd-${version}" "initramfs-${version}.img" \ -+ "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ -+ "initrd-${alt_version}" "initramfs-${alt_version}.img" \ -+ "initramfs-genkernel-${version}" \ -+ "initramfs-genkernel-${alt_version}" \ -+ "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \ -+ "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do -+ if test -e "${dirname}/${i}" ; then -+ initrd_real="${i}" -+ break -+ fi -+ done -+ -+ initrd= -+ if test -n "${initrd_early}" || test -n "${initrd_real}"; then -+ initrd="${initrd_early} ${initrd_real}" -+ -+ initrd_display= -+ for i in ${initrd}; do -+ initrd_display="${initrd_display} ${dirname}/${i}" -+ done -+ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -+ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 -+ fi -+ fi -+ -+ fdt= -+ for i in "dtb-${version}" "dtb-${alt_version}"; do -+ if test -f "${dirname}/${i}/${GRUB_DEFAULT_DTB}" ; then -+ fdt="${i}/${GRUB_DEFAULT_DTB}" -+ break -+ fi -+ done -+ -+ config= -+ for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do -+ if test -e "${i}" ; then -+ config="${i}" -+ break -+ fi -+ done -+ -+ initramfs= -+ if test -n "${config}" ; then -+ initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` -+ fi -+ -+ if test -z "${initramfs}" && test -z "${initrd_real}" ; then -+ # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's -+ # no initrd or builtin initramfs, it can't work here. -+ if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ -+ || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then -+ -+ linux_root_device_thisversion=${GRUB_DEVICE} -+ else -+ linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} -+ fi -+ fi -+ -+ if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then -+ GRUB_DISABLE_SUBMENU="true" -+ fi -+ -+ if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then -+ linux_entry "${OS}" "${version}" simple standard \ -+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -+ linux_entry "${OS}" "${version}" simple debug \ -+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" -+ fi -+ -+ submenu_indentation="$grub_tab" -+ -+ if [ -z "$boot_device_id" ]; then -+ boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -+ fi -+ # TRANSLATORS: %s is replaced with an OS name -+ echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {" -+ is_top_level=false -+ fi -+ -+ linux_entry "${OS}" "${version}" advanced standard \ -+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -+ linux_entry "${OS}" "${version}" advanced debug \ -+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" -+ fi -+ -+ if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then -+ linux_entry "${OS}" "${version}" recovery standard \ -+ "single ${GRUB_CMDLINE_LINUX}" -+ fi -+ -+ list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` -+done -+ -+# If at least one kernel was found, then we need to -+# add a closing '}' for the submenu command. -+if [ x"$is_top_level" != xtrue ]; then -+ echo '}' -+fi -+ -+echo "$title_correction_code" diff --git a/0129-Add-auto-hide-menu-support.patch b/0095-Add-auto-hide-menu-support.patch similarity index 94% rename from 0129-Add-auto-hide-menu-support.patch rename to 0095-Add-auto-hide-menu-support.patch index 0afa74a..6451115 100644 --- a/0129-Add-auto-hide-menu-support.patch +++ b/0095-Add-auto-hide-menu-support.patch @@ -49,10 +49,10 @@ Changes in v2: create mode 100644 util/grub.d/01_menu_auto_hide.in diff --git a/Makefile.util.def b/Makefile.util.def -index c13ca685ce1..026b458bb85 100644 +index 41906486a71..04551e095bd 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -457,6 +457,12 @@ script = { +@@ -458,6 +458,12 @@ script = { installdir = grubconf; }; @@ -120,10 +120,10 @@ index 00000000000..ad175870a54 +fi +EOF diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 13a3a6bc752..ab634393a31 100644 +index 9d6ea55bdd3..21bbace4647 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in -@@ -42,6 +42,7 @@ if [ -z "${OSPROBED}" ] ; then +@@ -45,6 +45,7 @@ if [ -z "${OSPROBED}" ] ; then fi osx_entry() { @@ -131,7 +131,7 @@ index 13a3a6bc752..ab634393a31 100644 # TRANSLATORS: it refers on the OS residing on device %s onstr="$(gettext_printf "(on %s)" "${DEVICE}")" hints="" -@@ -102,6 +103,7 @@ for OS in ${OSPROBED} ; do +@@ -105,6 +106,7 @@ for OS in ${OSPROBED} ; do case ${BOOT} in chain) @@ -139,7 +139,7 @@ index 13a3a6bc752..ab634393a31 100644 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF -@@ -132,6 +134,7 @@ EOF +@@ -135,6 +137,7 @@ EOF EOF ;; efi) @@ -147,7 +147,7 @@ index 13a3a6bc752..ab634393a31 100644 EFIPATH=${DEVICE#*@} DEVICE=${DEVICE%@*} -@@ -176,6 +179,7 @@ EOF +@@ -179,6 +182,7 @@ EOF LINITRD="${LINITRD#/boot}" fi @@ -155,7 +155,7 @@ index 13a3a6bc752..ab634393a31 100644 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" recovery_params="$(echo "${LPARAMS}" | grep single)" || true counter=1 -@@ -249,6 +253,7 @@ EOF +@@ -260,6 +264,7 @@ EOF done ;; hurd) @@ -163,7 +163,7 @@ index 13a3a6bc752..ab634393a31 100644 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' { -@@ -275,6 +280,7 @@ EOF +@@ -286,6 +291,7 @@ EOF EOF ;; minix) @@ -171,8 +171,8 @@ index 13a3a6bc752..ab634393a31 100644 cat << EOF menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" { EOF -@@ -306,3 +312,15 @@ EOF - esac +@@ -302,3 +308,15 @@ EOF + ;; esac done + diff --git a/0131-Add-grub-set-bootflag-utility.patch b/0096-Add-grub-set-bootflag-utility.patch similarity index 97% rename from 0131-Add-grub-set-bootflag-utility.patch rename to 0096-Add-grub-set-bootflag-utility.patch index ff66909..f5ff7d3 100644 --- a/0131-Add-grub-set-bootflag-utility.patch +++ b/0096-Add-grub-set-bootflag-utility.patch @@ -45,10 +45,10 @@ Signed-off-by: Hans de Goede create mode 100644 util/grub-set-bootflag.1 diff --git a/Makefile.util.def b/Makefile.util.def -index 89a9da1b9f7..125ad6209b2 100644 +index 04551e095bd..c6375933faa 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1451,3 +1451,10 @@ program = { +@@ -1445,3 +1445,10 @@ program = { ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -226,7 +226,7 @@ index 00000000000..bb198f02351 + return 0; +} diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index 58d7d9540be..375b1bf9b02 100644 +index b909f2c073a..ea58362b555 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -14,6 +14,9 @@ EXTRA_DIST += util/import_unicode.py @@ -265,7 +265,7 @@ index 00000000000..5d8fcba21aa +OnActiveSec=2min diff --git a/util/grub-set-bootflag.1 b/util/grub-set-bootflag.1 new file mode 100644 -index 00000000000..f121226b416 +index 00000000000..57801da22a0 --- /dev/null +++ b/util/grub-set-bootflag.1 @@ -0,0 +1,20 @@ @@ -284,7 +284,7 @@ index 00000000000..f121226b416 +.TP +\fBBOOTFLAG\fR +.RS 7 -+Bootflag to set, one of \fIboot_success\fR or \fImenu_show_once\fR. ++Bootflag to set, one of \fIboot_success\fR or \fIshow_menu_once\fR. +.RE + +.SH SEE ALSO diff --git a/0132-docs-Add-grub-boot-indeterminate.service-example.patch b/0097-docs-Add-grub-boot-indeterminate.service-example.patch similarity index 100% rename from 0132-docs-Add-grub-boot-indeterminate.service-example.patch rename to 0097-docs-Add-grub-boot-indeterminate.service-example.patch diff --git a/0133-gentpl-add-disable-support.patch b/0098-gentpl-add-disable-support.patch similarity index 97% rename from 0133-gentpl-add-disable-support.patch rename to 0098-gentpl-add-disable-support.patch index 90308d8..2c3c998 100644 --- a/0133-gentpl-add-disable-support.patch +++ b/0098-gentpl-add-disable-support.patch @@ -9,7 +9,7 @@ Signed-off-by: Peter Jones 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gentpl.py b/gentpl.py -index f05812eace3..3a0c04963aa 100644 +index 2cba0bbbd6f..628e8bec1d7 100644 --- a/gentpl.py +++ b/gentpl.py @@ -592,11 +592,21 @@ def platform_conditional(platform, closure): diff --git a/0099-Add-grub_debug_enabled.patch b/0099-Add-grub_debug_enabled.patch deleted file mode 100644 index 838913c..0000000 --- a/0099-Add-grub_debug_enabled.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 30 Nov 2017 15:11:39 -0500 -Subject: [PATCH] Add grub_debug_enabled() - ---- - grub-core/kern/misc.c | 21 ++++++++++++++++----- - include/grub/misc.h | 1 + - 2 files changed, 17 insertions(+), 5 deletions(-) - -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 636f97e1ba1..e758ab3416d 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -159,17 +159,28 @@ int grub_err_printf (const char *fmt, ...) - __attribute__ ((alias("grub_printf"))); - #endif - -+int -+grub_debug_enabled (const char * condition) -+{ -+ const char *debug; -+ -+ debug = grub_env_get ("debug"); -+ if (!debug) -+ return 0; -+ -+ if (grub_strword (debug, "all") || grub_strword (debug, condition)) -+ return 1; -+ -+ return 0; -+} -+ - void - grub_real_dprintf (const char *file, const int line, const char *condition, - const char *fmt, ...) - { - va_list args; -- const char *debug = grub_env_get ("debug"); - -- if (! debug) -- return; -- -- if (grub_strword (debug, "all") || grub_strword (debug, condition)) -+ if (grub_debug_enabled (condition)) - { - grub_printf ("%s:%d: ", file, line); - va_start (args, fmt); -diff --git a/include/grub/misc.h b/include/grub/misc.h -index b4339222ecb..4a4f485a5f6 100644 ---- a/include/grub/misc.h -+++ b/include/grub/misc.h -@@ -367,6 +367,7 @@ grub_puts (const char *s) - } - - int EXPORT_FUNC(grub_puts_) (const char *s); -+int EXPORT_FUNC(grub_debug_enabled) (const char *condition); - void EXPORT_FUNC(grub_real_dprintf) (const char *file, - const int line, - const char *condition, diff --git a/0134-gentpl-add-pc-firmware-type.patch b/0099-gentpl-add-pc-firmware-type.patch similarity index 95% rename from 0134-gentpl-add-pc-firmware-type.patch rename to 0099-gentpl-add-pc-firmware-type.patch index 9f0fd47..96dd2b8 100644 --- a/0134-gentpl-add-pc-firmware-type.patch +++ b/0099-gentpl-add-pc-firmware-type.patch @@ -9,7 +9,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+) diff --git a/gentpl.py b/gentpl.py -index 3a0c04963aa..1d9dda430e7 100644 +index 628e8bec1d7..34a4eba2b42 100644 --- a/gentpl.py +++ b/gentpl.py @@ -51,6 +51,7 @@ GROUPS["riscv32"] = [ "riscv32_efi" ] diff --git a/0135-efinet-also-use-the-firmware-acceleration-for-http.patch b/0100-efinet-also-use-the-firmware-acceleration-for-http.patch similarity index 100% rename from 0135-efinet-also-use-the-firmware-acceleration-for-http.patch rename to 0100-efinet-also-use-the-firmware-acceleration-for-http.patch diff --git a/0136-efi-http-Make-root_url-reflect-the-protocol-hostname.patch b/0101-efi-http-Make-root_url-reflect-the-protocol-hostname.patch similarity index 100% rename from 0136-efi-http-Make-root_url-reflect-the-protocol-hostname.patch rename to 0101-efi-http-Make-root_url-reflect-the-protocol-hostname.patch diff --git a/0137-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch b/0102-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch similarity index 96% rename from 0137-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch rename to 0102-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch index 403412b..6afb91c 100644 --- a/0137-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch +++ b/0102-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch @@ -17,10 +17,10 @@ Signed-off-by: Peter Jones 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac -index 8ee18ba159a..cf327482e8a 100644 +index f4cfd06cbe6..dbf97e703b4 100644 --- a/configure.ac +++ b/configure.ac -@@ -868,11 +868,23 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p +@@ -877,11 +877,23 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow" fi @@ -45,7 +45,7 @@ index 8ee18ba159a..cf327482e8a 100644 AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [ grub_cv_target_cc_soft_float=no if test "x$target_cpu" = xarm64; then -@@ -1951,6 +1963,41 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" +@@ -2018,6 +2030,41 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" @@ -88,7 +88,7 @@ index 8ee18ba159a..cf327482e8a 100644 GRUB_PLATFORM="${platform}" diff --git a/conf/Makefile.common b/conf/Makefile.common -index 5e8ba2ae3b0..bbf33b0bc4a 100644 +index 5f0ef969857..2ff9b39357c 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -40,24 +40,25 @@ CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 @@ -129,7 +129,7 @@ index 5e8ba2ae3b0..bbf33b0bc4a 100644 # Other variables diff --git a/gentpl.py b/gentpl.py -index 1d9dda430e7..95fe1a24d8a 100644 +index 34a4eba2b42..59f62ef9522 100644 --- a/gentpl.py +++ b/gentpl.py @@ -697,10 +697,10 @@ def module(defn, platform): diff --git a/0138-module-verifier-make-it-possible-to-run-checkers-on-.patch b/0103-module-verifier-make-it-possible-to-run-checkers-on-.patch similarity index 100% rename from 0138-module-verifier-make-it-possible-to-run-checkers-on-.patch rename to 0103-module-verifier-make-it-possible-to-run-checkers-on-.patch diff --git a/0139-Rework-how-the-fdt-command-builds.patch b/0104-Rework-how-the-fdt-command-builds.patch similarity index 92% rename from 0139-Rework-how-the-fdt-command-builds.patch rename to 0104-Rework-how-the-fdt-command-builds.patch index 9936858..71328da 100644 --- a/0139-Rework-how-the-fdt-command-builds.patch +++ b/0104-Rework-how-the-fdt-command-builds.patch @@ -22,10 +22,10 @@ Signed-off-by: Peter Jones 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 48491b50683..556adca7074 100644 +index c40170f2dd2..84a3d89de9a 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -175,7 +175,6 @@ kernel = { +@@ -177,7 +177,6 @@ kernel = { arm_coreboot = kern/arm/coreboot/init.c; arm_coreboot = kern/arm/coreboot/timer.c; arm_coreboot = kern/arm/coreboot/coreboot.S; @@ -33,7 +33,7 @@ index 48491b50683..556adca7074 100644 arm_coreboot = bus/fdt.c; arm_coreboot = term/ps2.c; arm_coreboot = term/arm/pl050.c; -@@ -348,6 +347,8 @@ kernel = { +@@ -351,6 +350,8 @@ kernel = { riscv64 = kern/riscv/cache_flush.S; riscv64 = kern/riscv/dl.c; @@ -42,7 +42,7 @@ index 48491b50683..556adca7074 100644 emu = disk/host.c; emu = kern/emu/cache_s.S; emu = kern/emu/hostdisk.c; -@@ -1801,7 +1802,6 @@ module = { +@@ -1825,7 +1826,6 @@ module = { riscv32 = loader/riscv/linux.c; riscv64 = loader/riscv/linux.c; emu = loader/emu/linux.c; @@ -50,7 +50,7 @@ index 48491b50683..556adca7074 100644 common = loader/linux.c; common = lib/cmdline.c; -@@ -1812,7 +1812,6 @@ module = { +@@ -1836,7 +1836,6 @@ module = { module = { name = fdt; efi = loader/efi/fdt.c; @@ -72,12 +72,12 @@ index 0d371c5633e..37e04bd69e7 100644 #define FDT_BEGIN_NODE 0x00000001 diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c -index ee9c5592c70..37ca407bb36 100644 +index c86f283d756..c572415d38a 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c -@@ -26,6 +26,8 @@ - #include +@@ -27,6 +27,8 @@ #include + #include +GRUB_MOD_LICENSE ("GPLv3+"); + @@ -105,7 +105,7 @@ index e609c7e4111..22b7c5463fc 100644 + #endif /* ! GRUB_FDT_HEADER */ diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index d9ad30052f1..ee9c4e4eb88 100644 +index f512573c0da..dd49939aaa9 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -76,6 +76,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h diff --git a/0140-Disable-non-wordsize-allocations-on-arm.patch b/0105-Disable-non-wordsize-allocations-on-arm.patch similarity index 93% rename from 0140-Disable-non-wordsize-allocations-on-arm.patch rename to 0105-Disable-non-wordsize-allocations-on-arm.patch index 64da8e6..3708cbe 100644 --- a/0140-Disable-non-wordsize-allocations-on-arm.patch +++ b/0105-Disable-non-wordsize-allocations-on-arm.patch @@ -9,10 +9,10 @@ Signed-off-by: Peter Jones 1 file changed, 20 insertions(+) diff --git a/configure.ac b/configure.ac -index cf327482e8a..9b0946c27bf 100644 +index dbf97e703b4..96b96973f26 100644 --- a/configure.ac +++ b/configure.ac -@@ -1262,6 +1262,26 @@ if test "x$target_cpu" = xarm; then +@@ -1288,6 +1288,26 @@ if test "x$target_cpu" = xarm; then done ]) diff --git a/0142-Prepend-prefix-when-HTTP-path-is-relative.patch b/0106-Prepend-prefix-when-HTTP-path-is-relative.patch similarity index 98% rename from 0142-Prepend-prefix-when-HTTP-path-is-relative.patch rename to 0106-Prepend-prefix-when-HTTP-path-is-relative.patch index 1b1af53..3592ef2 100644 --- a/0142-Prepend-prefix-when-HTTP-path-is-relative.patch +++ b/0106-Prepend-prefix-when-HTTP-path-is-relative.patch @@ -14,10 +14,10 @@ Signed-off-by: Peter Jones 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index da47b18b50e..dcf48726d54 100644 +index d1de9fa6873..1c540fc8c26 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c -@@ -130,11 +130,19 @@ grub_set_prefix_and_root (void) +@@ -131,11 +131,19 @@ grub_set_prefix_and_root (void) if (fwdevice && fwpath) { char *fw_path; diff --git a/0144-Make-grub_error-more-verbose.patch b/0107-Make-grub_error-more-verbose.patch similarity index 51% rename from 0144-Make-grub_error-more-verbose.patch rename to 0107-Make-grub_error-more-verbose.patch index ec4a3eb..2492e9f 100644 --- a/0144-Make-grub_error-more-verbose.patch +++ b/0107-Make-grub_error-more-verbose.patch @@ -5,50 +5,10 @@ Subject: [PATCH] Make grub_error() more verbose Signed-off-by: Peter Jones --- - grub-core/kern/efi/mm.c | 17 ++++++++++++++--- - grub-core/kern/err.c | 13 +++++++++++-- - include/grub/err.h | 5 ++++- - 3 files changed, 29 insertions(+), 6 deletions(-) + grub-core/kern/err.c | 13 +++++++++++-- + include/grub/err.h | 8 ++++++-- + 2 files changed, 17 insertions(+), 4 deletions(-) -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index a9e37108c6d..15595a46e23 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -157,12 +157,20 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, - - /* Limit the memory access to less than 4GB for 32-bit platforms. */ - if (address > GRUB_EFI_MAX_USABLE_ADDRESS) -- return 0; -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, -+ N_("invalid memory address (0x%llx > 0x%llx)"), -+ address, GRUB_EFI_MAX_USABLE_ADDRESS); -+ return NULL; -+ } - - b = grub_efi_system_table->boot_services; - status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); - if (status != GRUB_EFI_SUCCESS) -- return 0; -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ return NULL; -+ } - - if (address == 0) - { -@@ -172,7 +180,10 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, - status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); - grub_efi_free_pages (0, pages); - if (status != GRUB_EFI_SUCCESS) -- return 0; -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ return NULL; -+ } - } - - grub_efi_store_alloc (address, pages); diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c index 53c734de70e..aebfe0cf839 100644 --- a/grub-core/kern/err.c @@ -81,17 +41,20 @@ index 53c734de70e..aebfe0cf839 100644 return n; diff --git a/include/grub/err.h b/include/grub/err.h -index 24ba9f5f592..b68bbec3c72 100644 +index b08d5d0de4c..c0f90ef07c8 100644 --- a/include/grub/err.h +++ b/include/grub/err.h -@@ -85,7 +85,10 @@ struct grub_error_saved +@@ -85,8 +85,12 @@ struct grub_error_saved extern grub_err_t EXPORT_VAR(grub_errno); extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG]; --grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...); -+grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const int line, const char *fmt, ...); +-grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...) +- __attribute__ ((format (GNU_PRINTF, 2, 3))); ++grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const int line, const char *fmt, ...) ++ __attribute__ ((format (GNU_PRINTF, 4, 5))); + +#define grub_error(n, fmt, ...) grub_error (n, __FILE__, __LINE__, fmt, ##__VA_ARGS__) ++ + void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_error_push) (void); diff --git a/0145-Make-reset-an-alias-for-the-reboot-command.patch b/0108-Make-reset-an-alias-for-the-reboot-command.patch similarity index 100% rename from 0145-Make-reset-an-alias-for-the-reboot-command.patch rename to 0108-Make-reset-an-alias-for-the-reboot-command.patch diff --git a/0147-Add-a-version-command.patch b/0109-Add-a-version-command.patch similarity index 96% rename from 0147-Add-a-version-command.patch rename to 0109-Add-a-version-command.patch index f08559b..749d319 100644 --- a/0147-Add-a-version-command.patch +++ b/0109-Add-a-version-command.patch @@ -17,10 +17,10 @@ Signed-off-by: Peter Jones create mode 100644 grub-core/commands/version.c diff --git a/configure.ac b/configure.ac -index 9b0946c27bf..bca7c2818af 100644 +index 96b96973f26..dabcbafc985 100644 --- a/configure.ac +++ b/configure.ac -@@ -303,6 +303,19 @@ AC_SUBST(target_cpu) +@@ -312,6 +312,19 @@ AC_SUBST(target_cpu) AC_SUBST(platform) # Define default variables @@ -41,10 +41,10 @@ index 9b0946c27bf..bca7c2818af 100644 have_with_bootdir=n AC_ARG_WITH([bootdir], diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 556adca7074..8bb1dafd0ac 100644 +index 84a3d89de9a..498ca11762a 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -576,6 +576,11 @@ image = { +@@ -579,6 +579,11 @@ image = { enable = mips_loongson; }; diff --git a/0148-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch b/0110-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch similarity index 91% rename from 0148-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch rename to 0110-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch index ac8ed7f..9afb315 100644 --- a/0148-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch +++ b/0110-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 4 files changed, 10 insertions(+) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c -index c3b578acf25..1a3eb6b8d77 100644 +index 0320115662f..7cdffe3ebd5 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -188,6 +188,8 @@ scan_disk (const char *name, int accept_diskfilter) @@ -24,16 +24,16 @@ index c3b578acf25..1a3eb6b8d77 100644 if (!accept_diskfilter && is_valid_diskfilter_name (name)) return 0; -@@ -1211,6 +1213,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id, +@@ -1212,6 +1214,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id, the same. */ - if (pv->disk && grub_disk_get_size (disk) >= pv->part_size) + if (pv->disk && grub_disk_native_sectors (disk) >= pv->part_size) return GRUB_ERR_NONE; + grub_dprintf ("diskfilter", "checking %s\n", disk->name); pv->disk = grub_disk_open (disk->name); if (!pv->disk) return grub_errno; diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c -index 9e20af70ee0..54c227b1c84 100644 +index f077b5f5535..fe8ba6e6c93 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -855,6 +855,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) diff --git a/0110-misc-fix-invalid-character-recongition-in-strto-l.patch b/0110-misc-fix-invalid-character-recongition-in-strto-l.patch deleted file mode 100644 index 4006028..0000000 --- a/0110-misc-fix-invalid-character-recongition-in-strto-l.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aaron Miller -Date: Fri, 29 Jul 2016 17:41:27 +0800 -Subject: [PATCH] misc: fix invalid character recongition in strto*l - -Would previously allow digits larger than the base and didn't check that -subtracting the difference from 0-9 to lowercase letters for characters -larger than 9 didn't result in a value lower than 9, which allowed the -parses: ` = 9, _ = 8, ^ = 7, ] = 6, \ = 5, and [ = 4 ---- - grub-core/kern/misc.c | 13 ++++++++----- - 1 file changed, 8 insertions(+), 5 deletions(-) - -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 0e89c483d5e..5c3899f0e5b 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -434,11 +434,14 @@ grub_strtoull (const char *str, char **end, int base) - unsigned long digit; - - digit = grub_tolower (*str) - '0'; -- if (digit >= 'a' - '0') -- digit += '0' - 'a' + 10; -- else if (digit > 9) -- break; -- -+ if (digit > 9) -+ { -+ digit += '0' - 'a' + 10; -+ /* digit <= 9 check is needed to keep chars larger than -+ '9' but less than 'a' from being read as numbers */ -+ if (digit >= (unsigned long) base || digit <= 9) -+ break; -+ } - if (digit >= (unsigned long) base) - break; - diff --git a/0149-arm-arm64-loader-Better-memory-allocation-and-error-.patch b/0111-arm-arm64-loader-Better-memory-allocation-and-error-.patch similarity index 89% rename from 0149-arm-arm64-loader-Better-memory-allocation-and-error-.patch rename to 0111-arm-arm64-loader-Better-memory-allocation-and-error-.patch index c912d24..5b18d9c 100644 --- a/0149-arm-arm64-loader-Better-memory-allocation-and-error-.patch +++ b/0111-arm-arm64-loader-Better-memory-allocation-and-error-.patch @@ -66,12 +66,12 @@ per-platform constraints on its given address are maintained. Signed-off-by: Peter Jones --- - grub-core/kern/efi/mm.c | 33 +++++++++++++----- - grub-core/loader/arm64/linux.c | 78 ++++++++++++++++++++++++++++++++---------- - 2 files changed, 84 insertions(+), 27 deletions(-) + grub-core/kern/efi/mm.c | 33 +++++++++++++++----- + grub-core/loader/arm64/linux.c | 68 +++++++++++++++++++++++++++++++----------- + 2 files changed, 76 insertions(+), 25 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 15595a46e23..1b14fa0694c 100644 +index 74360542062..e6abc923db2 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -154,6 +154,7 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, @@ -82,7 +82,7 @@ index 15595a46e23..1b14fa0694c 100644 /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address > GRUB_EFI_MAX_USABLE_ADDRESS) -@@ -165,19 +166,22 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, +@@ -166,19 +167,22 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } b = grub_efi_system_table->boot_services; @@ -109,7 +109,7 @@ index 15595a46e23..1b14fa0694c 100644 grub_efi_free_pages (0, pages); if (status != GRUB_EFI_SUCCESS) { -@@ -186,9 +190,9 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, +@@ -187,9 +191,9 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } } @@ -121,7 +121,7 @@ index 15595a46e23..1b14fa0694c 100644 } void * -@@ -699,8 +703,21 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) +@@ -709,8 +713,21 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) for (desc = memory_map, *base_addr = GRUB_EFI_MAX_USABLE_ADDRESS; (grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size); desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) @@ -146,10 +146,10 @@ index 15595a46e23..1b14fa0694c 100644 grub_free(memory_map); diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 4c0a09c06de..8791b35b6fe 100644 +index 04994d5c67d..70a0075ec5e 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c -@@ -71,13 +71,15 @@ finalize_params_linux (void) +@@ -71,20 +71,25 @@ finalize_params_linux (void) { grub_efi_loaded_image_t *loaded_image = NULL; int node, retval, len; @@ -168,26 +168,7 @@ index 4c0a09c06de..8791b35b6fe 100644 node = grub_fdt_find_subnode (fdt, 0, "chosen"); if (node < 0) -@@ -88,17 +90,26 @@ finalize_params_linux (void) - */ - retval = grub_fdt_set_prop32(fdt, 0, "#address-cells", 2); - if (retval) -- goto failure; -+ { -+ err = grub_error(retval, "Could not find #address-cells"); -+ goto failure; -+ } - - retval = grub_fdt_set_prop32(fdt, 0, "#size-cells", 2); - if (retval) -- goto failure; -+ { -+ err = grub_error(retval, "Could not find #size-cells"); -+ goto failure; -+ } - - node = grub_fdt_add_subnode (fdt, 0, "chosen"); - } + node = grub_fdt_add_subnode (fdt, 0, "chosen"); if (node < 1) - goto failure; @@ -198,7 +179,7 @@ index 4c0a09c06de..8791b35b6fe 100644 /* Set initrd info */ if (initrd_start && initrd_end > initrd_start) -@@ -109,15 +120,26 @@ finalize_params_linux (void) +@@ -95,15 +100,26 @@ finalize_params_linux (void) retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start", initrd_start); if (retval) @@ -229,7 +210,7 @@ index 4c0a09c06de..8791b35b6fe 100644 grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", fdt); -@@ -125,14 +147,20 @@ finalize_params_linux (void) +@@ -111,14 +127,20 @@ finalize_params_linux (void) /* Convert command line to UCS-2 */ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); if (!loaded_image) @@ -252,7 +233,7 @@ index 4c0a09c06de..8791b35b6fe 100644 loaded_image->load_options_size = 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, -@@ -142,7 +170,7 @@ finalize_params_linux (void) +@@ -128,7 +150,7 @@ finalize_params_linux (void) failure: grub_fdt_unload(); @@ -261,7 +242,7 @@ index 4c0a09c06de..8791b35b6fe 100644 } static void -@@ -226,16 +254,28 @@ grub_linux_unload (void) +@@ -212,16 +234,28 @@ grub_linux_unload (void) static void * allocate_initrd_mem (int initrd_pages) { diff --git a/0150-Try-to-pick-better-locations-for-kernel-and-initrd.patch b/0112-Try-to-pick-better-locations-for-kernel-and-initrd.patch similarity index 97% rename from 0150-Try-to-pick-better-locations-for-kernel-and-initrd.patch rename to 0112-Try-to-pick-better-locations-for-kernel-and-initrd.patch index 25ad649..0bceecb 100644 --- a/0150-Try-to-pick-better-locations-for-kernel-and-initrd.patch +++ b/0112-Try-to-pick-better-locations-for-kernel-and-initrd.patch @@ -34,7 +34,7 @@ Signed-off-by: Peter Jones 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 1b14fa0694c..d70e5b45b7c 100644 +index e6abc923db2..83d7644222e 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -122,7 +122,7 @@ grub_efi_allocate_pages_max (grub_efi_physical_address_t max, @@ -46,7 +46,7 @@ index 1b14fa0694c..d70e5b45b7c 100644 return 0; b = grub_efi_system_table->boot_services; -@@ -466,7 +466,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -476,7 +476,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, { if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY #if 1 @@ -55,7 +55,7 @@ index 1b14fa0694c..d70e5b45b7c 100644 #endif && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000 && desc->num_pages != 0) -@@ -484,9 +484,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -494,9 +494,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, #if 1 if (BYTES_TO_PAGES (filtered_desc->physical_start) + filtered_desc->num_pages diff --git a/0151-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch b/0113-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch similarity index 93% rename from 0151-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch rename to 0113-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch index db05a0f..c2f2a59 100644 --- a/0151-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch +++ b/0113-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch @@ -16,16 +16,16 @@ Signed-off-by: Peter Jones util/grub-probe.c | 2 +- util/grub-rpm-sort.c | 2 +- util/setup.c | 2 +- - bootstrap.conf | 2 +- + bootstrap.conf | 3 +- .../gnulib-patches/fix-sign-compare-errors.patch | 161 +++++++++++++++++++++ - 13 files changed, 180 insertions(+), 18 deletions(-) + 13 files changed, 181 insertions(+), 18 deletions(-) create mode 100644 grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index 245b69cab51..7a8d9e62300 100644 +index eeea092752d..f08a1bb8415 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c -@@ -177,7 +177,7 @@ grub_util_get_image_size (const char *path) +@@ -189,7 +189,7 @@ grub_util_get_image_size (const char *path) sz = ftello (f); if (sz < 0) grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); @@ -35,19 +35,19 @@ index 245b69cab51..7a8d9e62300 100644 ret = (size_t) sz; diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c -index ee9fa7b4feb..19c20085279 100644 +index 467305b46ab..79037c093f7 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c -@@ -156,7 +156,7 @@ static void +@@ -157,7 +157,7 @@ static void rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs) { gf_single_t *rs_polynomial; - int i, j; + unsigned int i, j; gf_single_t *m; - m = xmalloc ((s + rs) * sizeof (gf_single_t)); + m = xcalloc (s + rs, sizeof (gf_single_t)); grub_memcpy (m, data, s * sizeof (gf_single_t)); -@@ -325,7 +325,7 @@ static void +@@ -324,7 +324,7 @@ static void encode_block (gf_single_t *ptr, grub_size_t s, gf_single_t *rptr, grub_size_t rs) { @@ -70,7 +70,7 @@ index c77d6085ccb..42a315031ff 100644 + fie1.fm_mapped_extents * sizeof (fie1.fm_extents[1])); diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 4c5a13022dc..2b7a626d5ea 100644 +index 28790307e00..9f730b35189 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -236,7 +236,7 @@ grub_find_root_devices_from_btrfs (const char *dir) @@ -83,7 +83,7 @@ index 4c5a13022dc..2b7a626d5ea 100644 fd = open (dir, 0); diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c -index 8b92f8528f9..370d02787cd 100644 +index da62f924e35..7bc99ac1c1d 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -83,7 +83,7 @@ grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_sec @@ -96,7 +96,7 @@ index 8b92f8528f9..370d02787cd 100644 if (log_secsize) diff --git a/util/grub-fstest.c b/util/grub-fstest.c -index f14e02d9727..88f9c5d4ad8 100644 +index 83865642009..bfcef852d83 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -323,7 +323,7 @@ cmd_cmp (char *src, char *dest) @@ -176,7 +176,7 @@ index 0fe45a6103d..3e09240b99f 100644 add_pixel (&data, &mask, glyph->bitmap.buffer[i / 8 + j * glyph->bitmap.pitch] & diff --git a/util/grub-probe.c b/util/grub-probe.c -index 81d27eead59..7481e487211 100644 +index c08e46bbb40..c6fac732b40 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -798,7 +798,7 @@ argp_parser (int key, char *arg, struct argp_state *state) @@ -202,10 +202,10 @@ index f33bd1ed568..8345944105f 100644 grub_util_host_init (&argc, &argv); diff --git a/util/setup.c b/util/setup.c -index 6f88f3cc43f..864094de682 100644 +index da5f2c07f50..8b22bb8ccac 100644 --- a/util/setup.c +++ b/util/setup.c -@@ -402,7 +402,7 @@ SETUP (const char *dir, +@@ -406,7 +406,7 @@ SETUP (const char *dir, int is_ldm; grub_err_t err; grub_disk_addr_t *sectors; @@ -215,15 +215,16 @@ index 6f88f3cc43f..864094de682 100644 unsigned int nsec, maxsec; diff --git a/bootstrap.conf b/bootstrap.conf -index 988dda099ac..8804d5beb89 100644 +index 6b043fc354c..186be9c48ce 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -78,7 +78,7 @@ cp -a INSTALL INSTALL.grub - +@@ -80,7 +80,8 @@ cp -a INSTALL INSTALL.grub bootstrap_post_import_hook () { set -e -- for patchname in fix-null-deref fix-width no-abort; do -+ for patchname in fix-null-deref fix-width no-abort fix-sign-compare-errors; do + for patchname in fix-base64 fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \ +- fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do ++ fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort \ ++ fix-sign-compare-errors; do patch -d grub-core/lib/gnulib -p2 \ < "grub-core/lib/gnulib-patches/$patchname.patch" done diff --git a/0152-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch b/0114-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch similarity index 92% rename from 0152-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch rename to 0114-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch index b2e5de0..668fb4c 100644 --- a/0152-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch +++ b/0114-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch @@ -11,10 +11,10 @@ Signed-off-by: Peter Jones 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac -index bca7c2818af..38d978bd650 100644 +index dabcbafc985..f691767a2c0 100644 --- a/configure.ac +++ b/configure.ac -@@ -1424,11 +1424,11 @@ fi +@@ -1480,11 +1480,11 @@ fi # Set them to their new values for the tests below. CC="$TARGET_CC" if test x"$platform" = xemu ; then @@ -29,7 +29,7 @@ index bca7c2818af..38d978bd650 100644 fi CPPFLAGS="$TARGET_CPPFLAGS" -@@ -1987,6 +1987,14 @@ if test x"$enable_werror" != xno ; then +@@ -2054,6 +2054,14 @@ if test x"$enable_werror" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Werror" fi @@ -45,7 +45,7 @@ index bca7c2818af..38d978bd650 100644 TARGET_CCAS=$TARGET_CC diff --git a/conf/Makefile.common b/conf/Makefile.common -index bbf33b0bc4a..b867691f125 100644 +index 2ff9b39357c..35e14ff017e 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -66,7 +66,7 @@ grubconfdir = $(sysconfdir)/grub.d diff --git a/0153-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch b/0115-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch similarity index 100% rename from 0153-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch rename to 0115-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch diff --git a/0154-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch b/0116-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch similarity index 100% rename from 0154-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch rename to 0116-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch diff --git a/0155-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch b/0117-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch similarity index 98% rename from 0155-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch rename to 0117-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch index 3bfb482..4ad0696 100644 --- a/0155-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch +++ b/0117-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch @@ -11,7 +11,7 @@ Signed-off-by: Peter Jones 1 file changed, 94 insertions(+), 73 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 5f48fa55619..075b77eb3e4 100644 +index 5f48fa55619..3e4f7ef39f4 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -47,6 +47,65 @@ static char *linux_cmdline; @@ -72,7 +72,7 @@ index 5f48fa55619..075b77eb3e4 100644 + } + + if (addr == NULL) -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, errmsg); ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, "%s", errmsg); + + return addr; +} diff --git a/0118-Fix-one-more-coverity-complaint.patch b/0118-Fix-one-more-coverity-complaint.patch deleted file mode 100644 index 41f4d0a..0000000 --- a/0118-Fix-one-more-coverity-complaint.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 25 May 2017 11:27:40 -0400 -Subject: [PATCH] Fix one more coverity complaint - -No idea why covscan thinks this is an "added" bug, since the file hasn't -changed in 3 years, but... yeah. - -Signed-off-by: Peter Jones ---- - grub-core/normal/completion.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c -index 596102848c1..c07100a8de3 100644 ---- a/grub-core/normal/completion.c -+++ b/grub-core/normal/completion.c -@@ -284,7 +284,8 @@ complete_file (void) - - /* Cut away the filename part. */ - dirfile = grub_strrchr (dir, '/'); -- dirfile[1] = '\0'; -+ if (dirfile) -+ dirfile[1] = '\0'; - - /* Iterate the directory. */ - (fs->fs_dir) (dev, dir, iterate_dir, NULL); diff --git a/0156-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch b/0118-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch similarity index 98% rename from 0156-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch rename to 0118-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch index f545a06..b1233ce 100644 --- a/0156-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch +++ b/0118-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 075b77eb3e4..50b7798d6e5 100644 +index 3e4f7ef39f4..6bc18d5aef5 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -52,13 +52,22 @@ struct allocation_choice { @@ -153,10 +153,10 @@ index 075b77eb3e4..50b7798d6e5 100644 grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start); diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index a093679cb80..91123b1eb5c 100644 +index 25ef52c04eb..fac22476cc5 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h -@@ -234,7 +234,11 @@ struct linux_kernel_params +@@ -236,7 +236,11 @@ struct linux_kernel_params grub_uint32_t ofw_cif_handler; /* b8 */ grub_uint32_t ofw_idt; /* bc */ diff --git a/0157-Fix-getroot.c-s-trampolines.patch b/0119-Fix-getroot.c-s-trampolines.patch similarity index 97% rename from 0157-Fix-getroot.c-s-trampolines.patch rename to 0119-Fix-getroot.c-s-trampolines.patch index 85fe933..29ec44c 100644 --- a/0157-Fix-getroot.c-s-trampolines.patch +++ b/0119-Fix-getroot.c-s-trampolines.patch @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 2b7a626d5ea..36429a7cd25 100644 +index 9f730b35189..f0c503f43d3 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -1264,22 +1264,20 @@ grub_util_get_grub_dev_os (const char *os_dev) diff --git a/0158-Do-not-allow-stack-trampolines-anywhere.patch b/0120-Do-not-allow-stack-trampolines-anywhere.patch similarity index 90% rename from 0158-Do-not-allow-stack-trampolines-anywhere.patch rename to 0120-Do-not-allow-stack-trampolines-anywhere.patch index 62b9463..46176d0 100644 --- a/0158-Do-not-allow-stack-trampolines-anywhere.patch +++ b/0120-Do-not-allow-stack-trampolines-anywhere.patch @@ -10,10 +10,10 @@ Signed-off-by: Peter Jones 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 38d978bd650..5076d635c57 100644 +index f691767a2c0..2e4b12adad3 100644 --- a/configure.ac +++ b/configure.ac -@@ -1995,6 +1995,9 @@ if test x"$enable_wextra" != xno ; then +@@ -2062,6 +2062,9 @@ if test x"$enable_wextra" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Wextra" fi @@ -24,7 +24,7 @@ index 38d978bd650..5076d635c57 100644 TARGET_CCAS=$TARGET_CC diff --git a/conf/Makefile.common b/conf/Makefile.common -index b867691f125..87c1f0e809b 100644 +index 35e14ff017e..0647c53b916 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -66,7 +66,7 @@ grubconfdir = $(sysconfdir)/grub.d diff --git a/0159-Reimplement-boot_counter.patch b/0121-Reimplement-boot_counter.patch similarity index 97% rename from 0159-Reimplement-boot_counter.patch rename to 0121-Reimplement-boot_counter.patch index 08c8c58..164b229 100644 --- a/0159-Reimplement-boot_counter.patch +++ b/0121-Reimplement-boot_counter.patch @@ -23,10 +23,10 @@ Signed-off-by: Christian Glombek create mode 100644 util/grub.d/01_fallback_counting.in diff --git a/Makefile.util.def b/Makefile.util.def -index 125ad6209b2..2019ebd0207 100644 +index c6375933faa..2e5e05b25f1 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -457,6 +457,12 @@ script = { +@@ -458,6 +458,12 @@ script = { installdir = grubconf; }; @@ -40,10 +40,10 @@ index 125ad6209b2..2019ebd0207 100644 name = '01_menu_auto_hide'; common = util/grub.d/01_menu_auto_hide.in; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 8bb1dafd0ac..65ca74f9ad9 100644 +index 498ca11762a..1e15345107e 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -395,6 +395,11 @@ kernel = { +@@ -398,6 +398,11 @@ kernel = { extra_dist = kern/mips/cache_flush.S; }; diff --git a/0121-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch b/0121-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch deleted file mode 100644 index 33cde3b..0000000 --- a/0121-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Wed, 1 Feb 2017 23:10:45 +0100 -Subject: [PATCH] grub-core/video/efi_gop.c: Add support for BLT_ONLY adapters - -EFI GOP has support for multiple different bitness types of frame buffers -and for a special "BLT only" type which is always defined to be RGBx. - -Because grub2 doesn't ever directly access the frame buffer but instead -only renders graphics via the BLT interface anyway, we can easily support -these adapters. - -The reason this has come up now is the emerging support for virtio-gpu -in OVMF. That adapter does not have the notion of a memory mapped frame -buffer and thus is BLT only. - -Signed-off-by: Alexander Graf ---- - grub-core/video/efi_gop.c | 2 ++ - include/grub/efi/graphics_output.h | 3 ++- - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c -index 7f9d1c2dfa1..c9e40e8d4e9 100644 ---- a/grub-core/video/efi_gop.c -+++ b/grub-core/video/efi_gop.c -@@ -121,6 +121,7 @@ grub_video_gop_get_bpp (struct grub_efi_gop_mode_info *in) - { - case GRUB_EFI_GOT_BGRA8: - case GRUB_EFI_GOT_RGBA8: -+ case GRUB_EFI_GOT_BLT_ONLY: - return 32; - - case GRUB_EFI_GOT_BITMASK: -@@ -187,6 +188,7 @@ grub_video_gop_fill_real_mode_info (unsigned mode, - switch (in->pixel_format) - { - case GRUB_EFI_GOT_RGBA8: -+ case GRUB_EFI_GOT_BLT_ONLY: - out->red_mask_size = 8; - out->red_field_pos = 0; - out->green_mask_size = 8; -diff --git a/include/grub/efi/graphics_output.h b/include/grub/efi/graphics_output.h -index 12977741192..e4388127c66 100644 ---- a/include/grub/efi/graphics_output.h -+++ b/include/grub/efi/graphics_output.h -@@ -28,7 +28,8 @@ typedef enum - { - GRUB_EFI_GOT_RGBA8, - GRUB_EFI_GOT_BGRA8, -- GRUB_EFI_GOT_BITMASK -+ GRUB_EFI_GOT_BITMASK, -+ GRUB_EFI_GOT_BLT_ONLY, - } - grub_efi_gop_pixel_format_t; - diff --git a/0161-Fix-menu-entry-selection-based-on-ID-and-title.patch b/0122-Fix-menu-entry-selection-based-on-ID-and-title.patch similarity index 100% rename from 0161-Fix-menu-entry-selection-based-on-ID-and-title.patch rename to 0122-Fix-menu-entry-selection-based-on-ID-and-title.patch diff --git a/0122-efi-uga-use-64-bit-for-fb_base.patch b/0122-efi-uga-use-64-bit-for-fb_base.patch deleted file mode 100644 index bafcb64..0000000 --- a/0122-efi-uga-use-64-bit-for-fb_base.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Andrei Borzenkov -Date: Wed, 16 May 2018 13:06:04 -0400 -Subject: [PATCH] efi/uga: use 64 bit for fb_base - -We get 64 bit from PCI BAR but then truncate by assigning to 32 bit. -Make sure to check that pointer does not overflow on 32 bit platform. - -Closes: 50931 ---- - grub-core/video/efi_uga.c | 31 ++++++++++++++++--------------- - 1 file changed, 16 insertions(+), 15 deletions(-) - -diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c -index 044af1d20d3..97a607c01a5 100644 ---- a/grub-core/video/efi_uga.c -+++ b/grub-core/video/efi_uga.c -@@ -34,7 +34,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - - static grub_efi_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID; - static struct grub_efi_uga_draw_protocol *uga; --static grub_uint32_t uga_fb; -+static grub_uint64_t uga_fb; - static grub_uint32_t uga_pitch; - - static struct -@@ -52,7 +52,7 @@ static struct - #define FBTEST_COUNT 8 - - static int --find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len) -+find_line_len (grub_uint64_t *fb_base, grub_uint32_t *line_len) - { - grub_uint32_t *base = (grub_uint32_t *) (grub_addr_t) *fb_base; - int i; -@@ -67,7 +67,7 @@ find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len) - { - if ((base[j] & RGB_MASK) == RGB_MAGIC) - { -- *fb_base = (grub_uint32_t) (grub_addr_t) base; -+ *fb_base = (grub_uint64_t) (grub_addr_t) base; - *line_len = j << 2; - - return 1; -@@ -84,7 +84,7 @@ find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len) - /* Context for find_framebuf. */ - struct find_framebuf_ctx - { -- grub_uint32_t *fb_base; -+ grub_uint64_t *fb_base; - grub_uint32_t *line_len; - int found; - }; -@@ -129,7 +129,9 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) - if (i == 5) - break; - -- old_bar2 = grub_pci_read (addr + 4); -+ i++; -+ addr += 4; -+ old_bar2 = grub_pci_read (addr); - } - else - old_bar2 = 0; -@@ -138,10 +140,15 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) - base64 <<= 32; - base64 |= (old_bar1 & GRUB_PCI_ADDR_MEM_MASK); - -- grub_dprintf ("fb", "%s(%d): 0x%llx\n", -+ grub_dprintf ("fb", "%s(%d): 0x%" PRIxGRUB_UINT64_T "\n", - ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ? -- "VMEM" : "MMIO"), i, -- (unsigned long long) base64); -+ "VMEM" : "MMIO"), type == GRUB_PCI_ADDR_MEM_TYPE_64 ? i - 1 : i, -+ base64); -+ -+#if GRUB_CPU_SIZEOF_VOID_P == 4 -+ if (old_bar2) -+ continue; -+#endif - - if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! ctx->found)) - { -@@ -149,12 +156,6 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) - if (find_line_len (ctx->fb_base, ctx->line_len)) - ctx->found++; - } -- -- if (type == GRUB_PCI_ADDR_MEM_TYPE_64) -- { -- i++; -- addr += 4; -- } - } - } - -@@ -162,7 +163,7 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) - } - - static int --find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len) -+find_framebuf (grub_uint64_t *fb_base, grub_uint32_t *line_len) - { - struct find_framebuf_ctx ctx = { - .fb_base = fb_base, diff --git a/0123-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch b/0123-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch deleted file mode 100644 index 20aadf6..0000000 --- a/0123-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch +++ /dev/null @@ -1,184 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Tue, 6 Mar 2018 17:11:15 +0100 -Subject: [PATCH] EFI: console: Do not set text-mode until we actually need it - -If we're running with a hidden menu we may never need text mode, so do not -change the video-mode to text until we actually need it. - -Signed-off-by: Hans de Goede ---- - grub-core/term/efi/console.c | 65 ++++++++++++++++++++++++++++++-------------- - 1 file changed, 44 insertions(+), 21 deletions(-) - -diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index 4840cc59d3f..051633d71e9 100644 ---- a/grub-core/term/efi/console.c -+++ b/grub-core/term/efi/console.c -@@ -24,6 +24,11 @@ - #include - #include - -+static grub_err_t grub_prepare_for_text_output(struct grub_term_output *term); -+ -+static int text_mode_available = -1; -+static int text_colorstate = -1; -+ - static grub_uint32_t - map_char (grub_uint32_t c) - { -@@ -66,14 +71,14 @@ map_char (grub_uint32_t c) - } - - static void --grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)), -+grub_console_putchar (struct grub_term_output *term, - const struct grub_unicode_glyph *c) - { - grub_efi_char16_t str[2 + 30]; - grub_efi_simple_text_output_interface_t *o; - unsigned i, j; - -- if (grub_efi_is_finished) -+ if (grub_prepare_for_text_output (term)) - return; - - o = grub_efi_system_table->con_out; -@@ -223,14 +228,15 @@ grub_console_getkey (struct grub_term_input *term) - } - - static struct grub_term_coordinate --grub_console_getwh (struct grub_term_output *term __attribute__ ((unused))) -+grub_console_getwh (struct grub_term_output *term) - { - grub_efi_simple_text_output_interface_t *o; - grub_efi_uintn_t columns, rows; - - o = grub_efi_system_table->con_out; -- if (grub_efi_is_finished || efi_call_4 (o->query_mode, o, o->mode->mode, -- &columns, &rows) != GRUB_EFI_SUCCESS) -+ if (grub_prepare_for_text_output (term) != GRUB_ERR_NONE || -+ efi_call_4 (o->query_mode, o, o->mode->mode, -+ &columns, &rows) != GRUB_EFI_SUCCESS) - { - /* Why does this fail? */ - columns = 80; -@@ -245,7 +251,7 @@ grub_console_getxy (struct grub_term_output *term __attribute__ ((unused))) - { - grub_efi_simple_text_output_interface_t *o; - -- if (grub_efi_is_finished) -+ if (grub_efi_is_finished || text_mode_available != 1) - return (struct grub_term_coordinate) { 0, 0 }; - - o = grub_efi_system_table->con_out; -@@ -253,12 +259,12 @@ grub_console_getxy (struct grub_term_output *term __attribute__ ((unused))) - } - - static void --grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)), -+grub_console_gotoxy (struct grub_term_output *term, - struct grub_term_coordinate pos) - { - grub_efi_simple_text_output_interface_t *o; - -- if (grub_efi_is_finished) -+ if (grub_prepare_for_text_output (term)) - return; - - o = grub_efi_system_table->con_out; -@@ -271,7 +277,7 @@ grub_console_cls (struct grub_term_output *term __attribute__ ((unused))) - grub_efi_simple_text_output_interface_t *o; - grub_efi_int32_t orig_attr; - -- if (grub_efi_is_finished) -+ if (grub_efi_is_finished || text_mode_available != 1) - return; - - o = grub_efi_system_table->con_out; -@@ -291,6 +297,12 @@ grub_console_setcolorstate (struct grub_term_output *term - if (grub_efi_is_finished) - return; - -+ if (text_mode_available != 1) { -+ /* Avoid "color_normal" environment writes causing a switch to textmode */ -+ text_colorstate = state; -+ return; -+ } -+ - o = grub_efi_system_table->con_out; - - switch (state) { -@@ -315,7 +327,7 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)), - { - grub_efi_simple_text_output_interface_t *o; - -- if (grub_efi_is_finished) -+ if (grub_efi_is_finished || text_mode_available != 1) - return; - - o = grub_efi_system_table->con_out; -@@ -323,18 +335,38 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)), - } - - static grub_err_t --grub_efi_console_output_init (struct grub_term_output *term) -+grub_prepare_for_text_output(struct grub_term_output *term) - { -- grub_efi_set_text_mode (1); -+ if (grub_efi_is_finished) -+ return GRUB_ERR_BAD_DEVICE; -+ -+ if (text_mode_available != -1) -+ return text_mode_available ? 0 : GRUB_ERR_BAD_DEVICE; -+ -+ if (! grub_efi_set_text_mode (1)) -+ { -+ /* This really should never happen */ -+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot set text mode"); -+ text_mode_available = 0; -+ return GRUB_ERR_BAD_DEVICE; -+ } -+ - grub_console_setcursor (term, 1); -+ if (text_colorstate != -1) -+ grub_console_setcolorstate (term, text_colorstate); -+ text_mode_available = 1; - return 0; - } - - static grub_err_t - grub_efi_console_output_fini (struct grub_term_output *term) - { -+ if (text_mode_available != 1) -+ return 0; -+ - grub_console_setcursor (term, 0); - grub_efi_set_text_mode (0); -+ text_mode_available = -1; - return 0; - } - -@@ -348,7 +380,6 @@ static struct grub_term_input grub_console_term_input = - static struct grub_term_output grub_console_term_output = - { - .name = "console", -- .init = grub_efi_console_output_init, - .fini = grub_efi_console_output_fini, - .putchar = grub_console_putchar, - .getwh = grub_console_getwh, -@@ -364,14 +395,6 @@ static struct grub_term_output grub_console_term_output = - void - grub_console_init (void) - { -- /* FIXME: it is necessary to consider the case where no console control -- is present but the default is already in text mode. */ -- if (! grub_efi_set_text_mode (1)) -- { -- grub_error (GRUB_ERR_BAD_DEVICE, "cannot set text mode"); -- return; -- } -- - grub_term_register_output ("console", &grub_console_term_output); - grub_term_register_input ("console", &grub_console_term_input); - } diff --git a/0162-Make-the-menu-entry-users-option-argument-to-be-opti.patch b/0123-Make-the-menu-entry-users-option-argument-to-be-opti.patch similarity index 97% rename from 0162-Make-the-menu-entry-users-option-argument-to-be-opti.patch rename to 0123-Make-the-menu-entry-users-option-argument-to-be-opti.patch index d560ec9..e0d36db 100644 --- a/0162-Make-the-menu-entry-users-option-argument-to-be-opti.patch +++ b/0123-Make-the-menu-entry-users-option-argument-to-be-opti.patch @@ -23,7 +23,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index 9faf2be0f64..29736f5cd03 100644 +index b194123eb67..b175a1b43b7 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -29,7 +29,7 @@ static const struct grub_arg_option options[] = diff --git a/0163-Add-efi-export-env-and-efi-load-env-commands.patch b/0124-Add-efi-export-env-and-efi-load-env-commands.patch similarity index 91% rename from 0163-Add-efi-export-env-and-efi-load-env-commands.patch rename to 0124-Add-efi-export-env-and-efi-load-env-commands.patch index 9b2ab56..73456bc 100644 --- a/0163-Add-efi-export-env-and-efi-load-env-commands.patch +++ b/0124-Add-efi-export-env-and-efi-load-env-commands.patch @@ -14,18 +14,17 @@ Signed-off-by: Peter Jones grub-core/kern/efi/efi.c | 3 + grub-core/kern/efi/init.c | 5 -- grub-core/lib/envblk.c | 43 +++++++++++ - util/editenv.c | 2 - util/grub-set-bootflag.c | 1 + include/grub/efi/efi.h | 5 ++ include/grub/lib/envblk.h | 3 + - 9 files changed, 229 insertions(+), 7 deletions(-) + 8 files changed, 229 insertions(+), 5 deletions(-) create mode 100644 grub-core/commands/efi/env.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 65ca74f9ad9..661994686e6 100644 +index 1e15345107e..81fc274148e 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -817,6 +817,12 @@ module = { +@@ -820,6 +820,12 @@ module = { enable = efi; }; @@ -40,7 +39,7 @@ index 65ca74f9ad9..661994686e6 100644 efi = commands/efi/efifwsetup.c; diff --git a/grub-core/commands/efi/env.c b/grub-core/commands/efi/env.c new file mode 100644 -index 00000000000..a69079786aa +index 00000000000..cbd13e03e81 --- /dev/null +++ b/grub-core/commands/efi/env.c @@ -0,0 +1,168 @@ @@ -96,8 +95,8 @@ index 00000000000..a69079786aa + if (argc != 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable name expected")); + -+ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &grub_env_guid, -+ &envblk_s.size); ++ grub_efi_get_variable ("GRUB_ENV", &grub_env_guid, &envblk_s.size, ++ (void **) &envblk_s.buf); + if (!envblk_s.buf || envblk_s.size < 1) + { + char *buf = grub_malloc (1025); @@ -185,8 +184,8 @@ index 00000000000..a69079786aa + struct grub_envblk envblk_s = { NULL, 0 }; + grub_envblk_t envblk = &envblk_s; + -+ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &grub_env_guid, -+ &envblk_s.size); ++ grub_efi_get_variable ("GRUB_ENV", &grub_env_guid, &envblk_s.size, ++ (void **) &envblk_s.buf); + if (!envblk_s.buf || envblk_s.size < 1) + return 0; + @@ -213,10 +212,10 @@ index 00000000000..a69079786aa + grub_unregister_command (loadenv_cmd); +} diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index ada3004cfba..279394d85eb 100644 +index 2a446f5031b..14bc10eb564 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -224,6 +224,9 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, +@@ -225,6 +225,9 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, if (status == GRUB_EFI_SUCCESS) return GRUB_ERR_NONE; @@ -227,10 +226,10 @@ index ada3004cfba..279394d85eb 100644 } diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index e6183a4c44d..d1afa3af11e 100644 +index 2d12e6188fd..0574d8d6217 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c -@@ -29,11 +29,6 @@ +@@ -85,11 +85,6 @@ stack_protector_init (void) grub_addr_t grub_modbase; @@ -243,7 +242,7 @@ index e6183a4c44d..d1afa3af11e 100644 static int set_var (const char *name, const char *value, diff --git a/grub-core/lib/envblk.c b/grub-core/lib/envblk.c -index 230e0e9d9ab..f89d86d4e8d 100644 +index 2e4e78b132d..874506da169 100644 --- a/grub-core/lib/envblk.c +++ b/grub-core/lib/envblk.c @@ -223,6 +223,49 @@ grub_envblk_delete (grub_envblk_t envblk, const char *name) @@ -296,19 +295,6 @@ index 230e0e9d9ab..f89d86d4e8d 100644 void grub_envblk_iterate (grub_envblk_t envblk, void *hook_data, -diff --git a/util/editenv.c b/util/editenv.c -index 1f7f6f3ae18..66f99f988ff 100644 ---- a/util/editenv.c -+++ b/util/editenv.c -@@ -30,8 +30,6 @@ - #include - #include - --#define DEFAULT_ENVBLK_SIZE 1024 -- - void - grub_util_create_envblk_file (const char *name) - { diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c index bb198f02351..6a79ee67444 100644 --- a/util/grub-set-bootflag.c @@ -322,7 +308,7 @@ index bb198f02351..6a79ee67444 100644 #include #include diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 8ca3981d7a1..d24afbadbf6 100644 +index 2e0691454b1..8dfc89a33b9 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -24,6 +24,11 @@ diff --git a/0124-EFI-console-Add-grub_console_read_key_stroke-helper-.patch b/0124-EFI-console-Add-grub_console_read_key_stroke-helper-.patch deleted file mode 100644 index 6da36b2..0000000 --- a/0124-EFI-console-Add-grub_console_read_key_stroke-helper-.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 6 Jun 2018 15:54:44 +0200 -Subject: [PATCH] EFI: console: Add grub_console_read_key_stroke() helper - function - -This is a preparation patch for adding getkeystatus() support to the -EFI console terminal input driver. - -We can get modifier status through the simple_text_input read_key_stroke -method, but if a non-modifier key is (also) pressed the read_key_stroke -call will consume that key from the firmware's queue. - -The new grub_console_read_key_stroke() helper buffers upto 1 key-stroke. -If it has a non-modifier key buffered, it will return that one, if its -buffer is empty, it will fills its buffer by getting a new key-stroke. - -If called with consume=1 it will empty its buffer after copying the -key-data to the callers buffer, this is how getkey() will use it. - -If called with consume=0 it will keep the last key-stroke buffered, this -is how getkeystatus() will call it. This means that if a non-modifier -key gets pressed, repeated getkeystatus() calls will return the modifiers -of that key-press until it is consumed by a getkey() call. - -Signed-off-by: Hans de Goede ---- - grub-core/term/efi/console.c | 51 ++++++++++++++++++++++++++++++++++---------- - 1 file changed, 40 insertions(+), 11 deletions(-) - -diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index 051633d71e9..3d36c5c701b 100644 ---- a/grub-core/term/efi/console.c -+++ b/grub-core/term/efi/console.c -@@ -157,27 +157,56 @@ grub_console_getkey_con (struct grub_term_input *term __attribute__ ((unused))) - return grub_efi_translate_key(key); - } - -+/* -+ * When more then just modifiers are pressed, our getkeystatus() consumes a -+ * press from the queue, this function buffers the press for the regular -+ * getkey() so that it does not get lost. -+ */ -+static int -+grub_console_read_key_stroke ( -+ grub_efi_simple_text_input_ex_interface_t *text_input, -+ grub_efi_key_data_t *key_data_ret, int *key_ret, -+ int consume) -+{ -+ static grub_efi_key_data_t key_data; -+ grub_efi_status_t status; -+ int key; -+ -+ if (!text_input) -+ return GRUB_ERR_EOF; -+ -+ key = grub_efi_translate_key (key_data.key); -+ if (key == GRUB_TERM_NO_KEY) { -+ status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data); -+ if (status != GRUB_EFI_SUCCESS) -+ return GRUB_ERR_EOF; -+ -+ key = grub_efi_translate_key (key_data.key); -+ } -+ -+ *key_data_ret = key_data; -+ *key_ret = key; -+ -+ if (consume) { -+ key_data.key.scan_code = 0; -+ key_data.key.unicode_char = 0; -+ } -+ -+ return 0; -+} -+ - static int - grub_console_getkey_ex(struct grub_term_input *term) - { - grub_efi_key_data_t key_data; -- grub_efi_status_t status; - grub_efi_uint32_t kss; - int key = -1; - -- grub_efi_simple_text_input_ex_interface_t *text_input = term->data; -- -- status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data); -- -- if (status != GRUB_EFI_SUCCESS) -+ if (grub_console_read_key_stroke (term->data, &key_data, &key, 1) || -+ key == GRUB_TERM_NO_KEY) - return GRUB_TERM_NO_KEY; - - kss = key_data.key_state.key_shift_state; -- key = grub_efi_translate_key(key_data.key); -- -- if (key == GRUB_TERM_NO_KEY) -- return GRUB_TERM_NO_KEY; -- - if (kss & GRUB_EFI_SHIFT_STATE_VALID) - { - if ((kss & GRUB_EFI_LEFT_SHIFT_PRESSED diff --git a/0125-EFI-console-Implement-getkeystatus-support.patch b/0125-EFI-console-Implement-getkeystatus-support.patch deleted file mode 100644 index 74fa253..0000000 --- a/0125-EFI-console-Implement-getkeystatus-support.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 6 Jun 2018 16:16:47 +0200 -Subject: [PATCH] EFI: console: Implement getkeystatus() support - -Implement getkeystatus() support. - -Note that if a non-modifier key gets pressed and repeated calls to -getkeystatus() are made then it will return the modifier status at the -time of the non-modifier key, until that key-press gets consumed by a -getkey() call. - -This is a side-effect of how the EFI simple-text-input protocol works -and cannot be avoided. - -Signed-off-by: Hans de Goede ---- - grub-core/term/efi/console.c | 34 ++++++++++++++++++++++++++++++++++ - 1 file changed, 34 insertions(+) - -diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index 3d36c5c701b..92dd4996bb7 100644 ---- a/grub-core/term/efi/console.c -+++ b/grub-core/term/efi/console.c -@@ -223,6 +223,39 @@ grub_console_getkey_ex(struct grub_term_input *term) - return key; - } - -+static int -+grub_console_getkeystatus(struct grub_term_input *term) -+{ -+ grub_efi_key_data_t key_data; -+ grub_efi_uint32_t kss; -+ int key, mods = 0; -+ -+ if (grub_efi_is_finished) -+ return 0; -+ -+ if (grub_console_read_key_stroke (term->data, &key_data, &key, 0)) -+ return 0; -+ -+ kss = key_data.key_state.key_shift_state; -+ if (kss & GRUB_EFI_SHIFT_STATE_VALID) -+ { -+ if (kss & GRUB_EFI_LEFT_SHIFT_PRESSED) -+ mods |= GRUB_TERM_STATUS_LSHIFT; -+ if (kss & GRUB_EFI_RIGHT_SHIFT_PRESSED) -+ mods |= GRUB_TERM_STATUS_RSHIFT; -+ if (kss & GRUB_EFI_LEFT_ALT_PRESSED) -+ mods |= GRUB_TERM_STATUS_LALT; -+ if (kss & GRUB_EFI_RIGHT_ALT_PRESSED) -+ mods |= GRUB_TERM_STATUS_RALT; -+ if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED) -+ mods |= GRUB_TERM_STATUS_LCTRL; -+ if (kss & GRUB_EFI_RIGHT_CONTROL_PRESSED) -+ mods |= GRUB_TERM_STATUS_RCTRL; -+ } -+ -+ return mods; -+} -+ - static grub_err_t - grub_efi_console_input_init (struct grub_term_input *term) - { -@@ -403,6 +436,7 @@ static struct grub_term_input grub_console_term_input = - { - .name = "console", - .getkey = grub_console_getkey, -+ .getkeystatus = grub_console_getkeystatus, - .init = grub_efi_console_input_init, - }; - diff --git a/0164-Make-it-possible-to-subtract-conditions-from-debug.patch b/0125-Make-it-possible-to-subtract-conditions-from-debug.patch similarity index 95% rename from 0164-Make-it-possible-to-subtract-conditions-from-debug.patch rename to 0125-Make-it-possible-to-subtract-conditions-from-debug.patch index c281ef6..fce51ea 100644 --- a/0164-Make-it-possible-to-subtract-conditions-from-debug.patch +++ b/0125-Make-it-possible-to-subtract-conditions-from-debug.patch @@ -14,10 +14,10 @@ Signed-off-by: Peter Jones 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index e21dd44c7cf..18a7dbf4cd7 100644 +index 9a2fae6398e..578bf51a5fc 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -163,12 +163,24 @@ int +@@ -164,12 +164,24 @@ int grub_debug_enabled (const char * condition) { const char *debug; diff --git a/0165-Export-all-variables-from-the-initial-context-when-c.patch b/0126-Export-all-variables-from-the-initial-context-when-c.patch similarity index 100% rename from 0165-Export-all-variables-from-the-initial-context-when-c.patch rename to 0126-Export-all-variables-from-the-initial-context-when-c.patch diff --git a/0126-Make-grub_getkeystatus-helper-funtion-available-ever.patch b/0126-Make-grub_getkeystatus-helper-funtion-available-ever.patch deleted file mode 100644 index 9840a55..0000000 --- a/0126-Make-grub_getkeystatus-helper-funtion-available-ever.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 6 Jun 2018 16:47:11 +0200 -Subject: [PATCH] Make grub_getkeystatus helper funtion available everywhere - -Move the grub_getkeystatus helper function from -grub-core/commands/keystatus.c to grub-core/kern/term.c -and export it so that it can be used outside of the -keystatus command code too. - -Signed-off-by: Hans de Goede ---- - grub-core/commands/keystatus.c | 18 ------------------ - grub-core/kern/term.c | 18 ++++++++++++++++++ - include/grub/term.h | 1 + - 3 files changed, 19 insertions(+), 18 deletions(-) - -diff --git a/grub-core/commands/keystatus.c b/grub-core/commands/keystatus.c -index 460cf4e7e50..ff3f5878163 100644 ---- a/grub-core/commands/keystatus.c -+++ b/grub-core/commands/keystatus.c -@@ -35,24 +35,6 @@ static const struct grub_arg_option options[] = - {0, 0, 0, 0, 0, 0} - }; - --static int --grub_getkeystatus (void) --{ -- int status = 0; -- grub_term_input_t term; -- -- if (grub_term_poll_usb) -- grub_term_poll_usb (0); -- -- FOR_ACTIVE_TERM_INPUTS(term) -- { -- if (term->getkeystatus) -- status |= term->getkeystatus (term); -- } -- -- return status; --} -- - static grub_err_t - grub_cmd_keystatus (grub_extcmd_context_t ctxt, - int argc __attribute__ ((unused)), -diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c -index 07720ee6746..93bd3378d18 100644 ---- a/grub-core/kern/term.c -+++ b/grub-core/kern/term.c -@@ -120,6 +120,24 @@ grub_getkey (void) - } - } - -+int -+grub_getkeystatus (void) -+{ -+ int status = 0; -+ grub_term_input_t term; -+ -+ if (grub_term_poll_usb) -+ grub_term_poll_usb (0); -+ -+ FOR_ACTIVE_TERM_INPUTS(term) -+ { -+ if (term->getkeystatus) -+ status |= term->getkeystatus (term); -+ } -+ -+ return status; -+} -+ - void - grub_refresh (void) - { -diff --git a/include/grub/term.h b/include/grub/term.h -index 8117e2a24da..c215133383f 100644 ---- a/include/grub/term.h -+++ b/include/grub/term.h -@@ -327,6 +327,7 @@ grub_term_unregister_output (grub_term_output_t term) - void grub_putcode (grub_uint32_t code, struct grub_term_output *term); - int EXPORT_FUNC(grub_getkey) (void); - int EXPORT_FUNC(grub_getkey_noblock) (void); -+int EXPORT_FUNC(grub_getkeystatus) (void); - void grub_cls (void); - void EXPORT_FUNC(grub_refresh) (void); - void grub_puts_terminal (const char *str, struct grub_term_output *term); diff --git a/0127-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch b/0127-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch deleted file mode 100644 index e62a619..0000000 --- a/0127-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Mon, 26 Mar 2018 16:15:53 +0200 -Subject: [PATCH] Accept ESC, F8 and holding SHIFT as user interrupt keys - -On some devices the ESC key is the hotkey to enter the BIOS/EFI setup -screen, making it really hard to time pressing it right. Besides that -ESC is also pretty hard to discover for a user who does not know it -will unhide the menu. - -This commit makes F8, which used to be the hotkey to show the Windows -boot menu during boot for a long long time, also interrupt sleeps / -stop the menu countdown. - -This solves the ESC gets into the BIOS setup and also somewhat solves -the discoverability issue, but leaves the timing issue unresolved. - -This commit fixes the timing issue by also adding support for keeping -SHIFT pressed during boot to stop the menu countdown. This matches -what Ubuntu is doing, which should also help with discoverability. - -Signed-off-by: Hans de Goede ---- - grub-core/commands/sleep.c | 2 +- - grub-core/kern/term.c | 16 ++++++++++++++++ - grub-core/normal/menu.c | 2 +- - include/grub/term.h | 1 + - 4 files changed, 19 insertions(+), 2 deletions(-) - -diff --git a/grub-core/commands/sleep.c b/grub-core/commands/sleep.c -index e77e7900fac..a1370b710c9 100644 ---- a/grub-core/commands/sleep.c -+++ b/grub-core/commands/sleep.c -@@ -55,7 +55,7 @@ grub_interruptible_millisleep (grub_uint32_t ms) - start = grub_get_time_ms (); - - while (grub_get_time_ms () - start < ms) -- if (grub_getkey_noblock () == GRUB_TERM_ESC) -+ if (grub_key_is_interrupt (grub_getkey_noblock ())) - return 1; - - return 0; -diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c -index 93bd3378d18..6cae4c23e7a 100644 ---- a/grub-core/kern/term.c -+++ b/grub-core/kern/term.c -@@ -138,6 +138,22 @@ grub_getkeystatus (void) - return status; - } - -+int -+grub_key_is_interrupt (int key) -+{ -+ /* ESC sometimes is the BIOS setup hotkey and may be hard to discover, also -+ check F8, which was the key to get the Windows bootmenu for a long time. */ -+ if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F8) -+ return 1; -+ -+ /* Pressing keys at the right time during boot is hard to time, also allow -+ interrupting sleeps / the menu countdown by keeping shift pressed. */ -+ if (grub_getkeystatus() & (GRUB_TERM_STATUS_LSHIFT|GRUB_TERM_STATUS_RSHIFT)) -+ return 1; -+ -+ return 0; -+} -+ - void - grub_refresh (void) - { -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 783bde55b9e..046a1fb2c84 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -655,7 +655,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) - if (entry >= 0) - break; - } -- if (key == GRUB_TERM_ESC) -+ if (grub_key_is_interrupt (key)) - { - timeout = -1; - break; -diff --git a/include/grub/term.h b/include/grub/term.h -index c215133383f..2b079c29b80 100644 ---- a/include/grub/term.h -+++ b/include/grub/term.h -@@ -328,6 +328,7 @@ void grub_putcode (grub_uint32_t code, struct grub_term_output *term); - int EXPORT_FUNC(grub_getkey) (void); - int EXPORT_FUNC(grub_getkey_noblock) (void); - int EXPORT_FUNC(grub_getkeystatus) (void); -+int EXPORT_FUNC(grub_key_is_interrupt) (int key); - void grub_cls (void); - void EXPORT_FUNC(grub_refresh) (void); - void grub_puts_terminal (const char *str, struct grub_term_output *term); diff --git a/0170-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch b/0127-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch similarity index 98% rename from 0170-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch rename to 0127-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch index 5c6c28e..9788fd5 100644 --- a/0170-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch +++ b/0127-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch @@ -18,10 +18,10 @@ In menu auto hide script, rename last_boot_ok var to menu_hide_ok rename util/grub.d/{01_menu_auto_hide.in => 12_menu_auto_hide.in} (58%) diff --git a/Makefile.util.def b/Makefile.util.def -index 2019ebd0207..1fa92caad4d 100644 +index 2e5e05b25f1..11ab2d6fad1 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -458,14 +458,14 @@ script = { +@@ -459,14 +459,14 @@ script = { }; script = { @@ -40,7 +40,7 @@ index 2019ebd0207..1fa92caad4d 100644 installdir = grubconf; }; -@@ -524,6 +524,12 @@ script = { +@@ -518,6 +518,12 @@ script = { condition = COND_HOST_LINUX; }; diff --git a/0171-Fix-systemctl-kexec-exit-status-check.patch b/0128-Fix-systemctl-kexec-exit-status-check.patch similarity index 100% rename from 0171-Fix-systemctl-kexec-exit-status-check.patch rename to 0128-Fix-systemctl-kexec-exit-status-check.patch diff --git a/0172-Print-grub-emu-linux-loader-messages-as-debug.patch b/0129-Print-grub-emu-linux-loader-messages-as-debug.patch similarity index 100% rename from 0172-Print-grub-emu-linux-loader-messages-as-debug.patch rename to 0129-Print-grub-emu-linux-loader-messages-as-debug.patch diff --git a/0173-Don-t-assume-that-boot-commands-will-only-return-on-.patch b/0130-Don-t-assume-that-boot-commands-will-only-return-on-.patch similarity index 80% rename from 0173-Don-t-assume-that-boot-commands-will-only-return-on-.patch rename to 0130-Don-t-assume-that-boot-commands-will-only-return-on-.patch index 34cff10..418a1ef 100644 --- a/0173-Don-t-assume-that-boot-commands-will-only-return-on-.patch +++ b/0130-Don-t-assume-that-boot-commands-will-only-return-on-.patch @@ -13,11 +13,11 @@ kexec call later succeeds. Signed-off-by: Javier Martinez Canillas --- - grub-core/normal/menu.c | 19 +++++++++++-------- - 1 file changed, 11 insertions(+), 8 deletions(-) + grub-core/normal/menu.c | 23 +++++++++++++---------- + 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index d4832f17699..9ea1f411814 100644 +index d4832f17699..14ceb9bb060 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -285,7 +285,7 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name) @@ -29,6 +29,24 @@ index d4832f17699..9ea1f411814 100644 grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) { grub_err_t err = GRUB_ERR_NONE; +@@ -302,7 +302,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; +- return; ++ return grub_errno; + } + + errs_before = grub_err_printed_errors; +@@ -315,7 +315,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) + grub_env_context_open (); + menu = grub_zalloc (sizeof (*menu)); + if (! menu) +- return; ++ return grub_errno; + grub_env_set_menu (menu); + if (auto_boot) + grub_env_set ("timeout", "0"); @@ -385,7 +385,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ()) diff --git a/0130-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch b/0130-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch deleted file mode 100644 index e461de9..0000000 --- a/0130-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Steve Langasek -Date: Mon, 13 Jan 2014 12:13:12 +0000 -Subject: [PATCH] Output a menu entry for firmware setup on UEFI FastBoot - systems - -If fastboot is enabled in the BIOS then often it is not possible to -enter the firmware setup menu, add a menu entry for this. - -hdegoede: Cherry picked the Ubuntu patch from: -https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/patches/uefi_firmware_setup.patch -Into the Fedora / RH grub version - -According to: -https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/copyright -The patch is licensed under GPL-3+ - -[hdegoede: fix use with /sys/firmware/efi/efivars] -Signed-off-by: Hans de Goede ---- - Makefile.util.def | 6 ++++++ - util/grub.d/30_uefi-firmware.in | 46 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 52 insertions(+) - create mode 100644 util/grub.d/30_uefi-firmware.in - -diff --git a/Makefile.util.def b/Makefile.util.def -index 026b458bb85..89a9da1b9f7 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -545,6 +545,12 @@ script = { - installdir = grubconf; - }; - -+script = { -+ name = '30_uefi-firmware'; -+ common = util/grub.d/30_uefi-firmware.in; -+ installdir = grubconf; -+}; -+ - script = { - name = '40_custom'; - common = util/grub.d/40_custom.in; -diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in -new file mode 100644 -index 00000000000..93ececffea7 ---- /dev/null -+++ b/util/grub.d/30_uefi-firmware.in -@@ -0,0 +1,46 @@ -+#! /bin/sh -+set -e -+ -+# grub-mkconfig helper script. -+# Copyright (C) 2012 Free Software Foundation, Inc. -+# -+# GRUB is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 3 of the License, or -+# (at your option) any later version. -+# -+# GRUB is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with GRUB. If not, see . -+ -+prefix="@prefix@" -+exec_prefix="@exec_prefix@" -+datarootdir="@datarootdir@" -+ -+export TEXTDOMAIN=@PACKAGE@ -+export TEXTDOMAINDIR="@localedir@" -+ -+. "@datadir@/@PACKAGE@/grub-mkconfig_lib" -+ -+efi_vars_dir=/sys/firmware/efi/efivars -+EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c -+OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE" -+ -+if [ -e "$OsIndications" ] && \ -+ [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b5)") & 1 ))" = 1 ]; then -+ LABEL="System setup" -+ -+ gettext_printf "Adding boot menu entry for EFI firmware configuration\n" >&2 -+ -+ onstr="$(gettext_printf "(on %s)" "${DEVICE}")" -+ -+ cat << EOF -+menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { -+ fwsetup -+} -+EOF -+fi diff --git a/0174-Fix-undefined-references-for-fdt-when-building-with-.patch b/0131-Fix-undefined-references-for-fdt-when-building-with-.patch similarity index 100% rename from 0174-Fix-undefined-references-for-fdt-when-building-with-.patch rename to 0131-Fix-undefined-references-for-fdt-when-building-with-.patch diff --git a/0175-Do-better-in-bootstrap.conf.patch b/0132-Do-better-in-bootstrap.conf.patch similarity index 95% rename from 0175-Do-better-in-bootstrap.conf.patch rename to 0132-Do-better-in-bootstrap.conf.patch index 3547c78..ec9d8ec 100644 --- a/0175-Do-better-in-bootstrap.conf.patch +++ b/0132-Do-better-in-bootstrap.conf.patch @@ -8,7 +8,7 @@ Subject: [PATCH] Do better in bootstrap.conf 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf -index 29a6a3e90e2..417cfe405f4 100644 +index 186be9c48ce..9259526e891 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -16,7 +16,13 @@ diff --git a/0176-Use-git-to-apply-gnulib-patches.patch b/0133-Use-git-to-apply-gnulib-patches.patch similarity index 70% rename from 0176-Use-git-to-apply-gnulib-patches.patch rename to 0133-Use-git-to-apply-gnulib-patches.patch index 0813bad..7654648 100644 --- a/0176-Use-git-to-apply-gnulib-patches.patch +++ b/0133-Use-git-to-apply-gnulib-patches.patch @@ -5,32 +5,95 @@ Subject: [PATCH] Use git to apply gnulib patches. Signed-off-by: Peter Jones --- - bootstrap.conf | 4 - + bootstrap.conf | 6 - + conf/Makefile.extra-dist | 10 - + grub-core/lib/gnulib-patches/fix-base64.patch | 21 -- grub-core/lib/gnulib-patches/fix-null-deref.patch | 13 -- + .../lib/gnulib-patches/fix-null-state-deref.patch | 12 -- + .../gnulib-patches/fix-regcomp-uninit-token.patch | 15 -- + .../gnulib-patches/fix-regexec-null-deref.patch | 12 -- .../gnulib-patches/fix-sign-compare-errors.patch | 161 --------------- + .../lib/gnulib-patches/fix-uninit-structure.patch | 11 -- + .../lib/gnulib-patches/fix-unused-value.patch | 14 -- grub-core/lib/gnulib-patches/fix-width.patch | 217 --------------------- grub-core/lib/gnulib-patches/no-abort.patch | 26 --- - 5 files changed, 421 deletions(-) + 12 files changed, 518 deletions(-) + delete mode 100644 grub-core/lib/gnulib-patches/fix-base64.patch delete mode 100644 grub-core/lib/gnulib-patches/fix-null-deref.patch + delete mode 100644 grub-core/lib/gnulib-patches/fix-null-state-deref.patch + delete mode 100644 grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch + delete mode 100644 grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch delete mode 100644 grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch + delete mode 100644 grub-core/lib/gnulib-patches/fix-uninit-structure.patch + delete mode 100644 grub-core/lib/gnulib-patches/fix-unused-value.patch delete mode 100644 grub-core/lib/gnulib-patches/fix-width.patch delete mode 100644 grub-core/lib/gnulib-patches/no-abort.patch diff --git a/bootstrap.conf b/bootstrap.conf -index 417cfe405f4..24ea40b2fc5 100644 +index 9259526e891..452f4d79b0d 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -84,10 +84,6 @@ cp -a INSTALL INSTALL.grub +@@ -85,12 +85,6 @@ cp -a INSTALL INSTALL.grub bootstrap_post_import_hook () { set -e -- for patchname in fix-null-deref fix-width no-abort fix-sign-compare-errors; do +- for patchname in fix-base64 fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \ +- fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort \ +- fix-sign-compare-errors; do - patch -d grub-core/lib/gnulib -p2 \ - < "grub-core/lib/gnulib-patches/$patchname.patch" - done - for flagvar in CPPFLAGS CFLAGS; do - sed -i -e "s/^AM_$flagvar =/AM_$flagvar = \$(HOST_$flagvar)/" grub-core/lib/gnulib/Makefile.am - done + for patchname in \ + 0001-Support-POTFILES-shell \ + 0002-Handle-gettext_printf-shell-function \ +diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist +index ea58362b555..8ddf22e6c99 100644 +--- a/conf/Makefile.extra-dist ++++ b/conf/Makefile.extra-dist +@@ -30,16 +30,6 @@ EXTRA_DIST += grub-core/gensymlist.sh + EXTRA_DIST += grub-core/genemuinit.sh + EXTRA_DIST += grub-core/genemuinitheader.sh + +-EXTRA_DIST += grub-core/lib/gnulib-patches/fix-base64.patch +-EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch +-EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-state-deref.patch +-EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch +-EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch +-EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch +-EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch +-EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch +-EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch +- + EXTRA_DIST += grub-core/lib/libgcrypt + EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic + EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h') +diff --git a/grub-core/lib/gnulib-patches/fix-base64.patch b/grub-core/lib/gnulib-patches/fix-base64.patch +deleted file mode 100644 +index 985db127971..00000000000 +--- a/grub-core/lib/gnulib-patches/fix-base64.patch ++++ /dev/null +@@ -1,21 +0,0 @@ +-diff --git a/lib/base64.h b/lib/base64.h +-index 9cd0183b8..185a2afa1 100644 +---- a/lib/base64.h +-+++ b/lib/base64.h +-@@ -21,8 +21,14 @@ +- /* Get size_t. */ +- # include +- +--/* Get bool. */ +--# include +-+#ifndef GRUB_POSIX_BOOL_DEFINED +-+typedef enum { false = 0, true = 1 } bool; +-+#define GRUB_POSIX_BOOL_DEFINED 1 +-+#endif +-+ +-+#ifndef _GL_ATTRIBUTE_CONST +-+# define _GL_ATTRIBUTE_CONST /* empty */ +-+#endif +- +- # ifdef __cplusplus +- extern "C" { diff --git a/grub-core/lib/gnulib-patches/fix-null-deref.patch b/grub-core/lib/gnulib-patches/fix-null-deref.patch deleted file mode 100644 index 8fafa153a47..00000000000 @@ -50,6 +113,63 @@ index 8fafa153a47..00000000000 - { - struct group *group; - struct parser *parser = state->pstate; +diff --git a/grub-core/lib/gnulib-patches/fix-null-state-deref.patch b/grub-core/lib/gnulib-patches/fix-null-state-deref.patch +deleted file mode 100644 +index 813ec09c8a1..00000000000 +--- a/grub-core/lib/gnulib-patches/fix-null-state-deref.patch ++++ /dev/null +@@ -1,12 +0,0 @@ +---- a/lib/argp-help.c 2020-10-28 14:32:19.189215988 +0000 +-+++ b/lib/argp-help.c 2020-10-28 14:38:21.204673940 +0000 +-@@ -145,7 +145,8 @@ +- if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin) +- { +- __argp_failure (state, 0, 0, +-- dgettext (state->root_argp->argp_domain, +-+ dgettext (state == NULL ? NULL +-+ : state->root_argp->argp_domain, +- "\ +- ARGP_HELP_FMT: %s value is less than or equal to %s"), +- "rmargin", up->name); +diff --git a/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch b/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch +deleted file mode 100644 +index 02e06315dff..00000000000 +--- a/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch ++++ /dev/null +@@ -1,15 +0,0 @@ +---- a/lib/regcomp.c 2020-11-24 17:06:08.159223858 +0000 +-+++ b/lib/regcomp.c 2020-11-24 17:06:15.630253923 +0000 +-@@ -3808,11 +3808,7 @@ +- create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, +- re_token_type_t type) +- { +-- re_token_t t; +--#if defined GCC_LINT || defined lint +-- memset (&t, 0, sizeof t); +--#endif +-- t.type = type; +-+ re_token_t t = { .type = type }; +- return create_token_tree (dfa, left, right, &t); +- } +- +diff --git a/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch b/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch +deleted file mode 100644 +index db6dac9c9e3..00000000000 +--- a/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch ++++ /dev/null +@@ -1,12 +0,0 @@ +---- a/lib/regexec.c 2020-10-21 14:25:35.310195912 +0000 +-+++ b/lib/regexec.c 2020-11-05 10:55:09.621542984 +0000 +-@@ -1692,6 +1692,9 @@ +- { +- Idx top = mctx->state_log_top; +- +-+ if (mctx->state_log == NULL) +-+ return REG_NOERROR; +-+ +- if ((next_state_log_idx >= mctx->input.bufs_len +- && mctx->input.bufs_len < mctx->input.len) +- || (next_state_log_idx >= mctx->input.valid_len diff --git a/grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch b/grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch deleted file mode 100644 index 479029c0565..00000000000 @@ -217,6 +337,43 @@ index 479029c0565..00000000000 - mctx->max_mb_elem_len = to - from; - return REG_NOERROR; - } +diff --git a/grub-core/lib/gnulib-patches/fix-uninit-structure.patch b/grub-core/lib/gnulib-patches/fix-uninit-structure.patch +deleted file mode 100644 +index 7b4d9f67af4..00000000000 +--- a/grub-core/lib/gnulib-patches/fix-uninit-structure.patch ++++ /dev/null +@@ -1,11 +0,0 @@ +---- a/lib/regcomp.c 2020-10-22 13:49:06.770168928 +0000 +-+++ b/lib/regcomp.c 2020-10-22 13:50:37.026528298 +0000 +-@@ -3662,7 +3662,7 @@ +- Idx alloc = 0; +- #endif /* not RE_ENABLE_I18N */ +- reg_errcode_t ret; +-- re_token_t br_token; +-+ re_token_t br_token = {0}; +- bin_tree_t *tree; +- +- sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); +diff --git a/grub-core/lib/gnulib-patches/fix-unused-value.patch b/grub-core/lib/gnulib-patches/fix-unused-value.patch +deleted file mode 100644 +index ba51f1bf223..00000000000 +--- a/grub-core/lib/gnulib-patches/fix-unused-value.patch ++++ /dev/null +@@ -1,14 +0,0 @@ +---- a/lib/regexec.c 2020-10-21 14:25:35.310195912 +0000 +-+++ b/lib/regexec.c 2020-10-21 14:32:07.961765604 +0000 +-@@ -828,7 +828,11 @@ +- break; +- if (__glibc_unlikely (err != REG_NOMATCH)) +- goto free_return; +-+#ifdef DEBUG +-+ /* Only used for assertion below when DEBUG is set, otherwise +-+ it will be over-written when we loop around. */ +- match_last = -1; +-+#endif +- } +- else +- break; /* We found a match. */ diff --git a/grub-core/lib/gnulib-patches/fix-width.patch b/grub-core/lib/gnulib-patches/fix-width.patch deleted file mode 100644 index 0a208ad08b5..00000000000 diff --git a/0179-Fix-build-error-with-the-fdt-module-on-risc-v.patch b/0134-Fix-build-error-with-the-fdt-module-on-risc-v.patch similarity index 100% rename from 0179-Fix-build-error-with-the-fdt-module-on-risc-v.patch rename to 0134-Fix-build-error-with-the-fdt-module-on-risc-v.patch diff --git a/0186-grub-set-bootflag-Update-comment-about-running-as-ro.patch b/0135-grub-set-bootflag-Update-comment-about-running-as-ro.patch similarity index 100% rename from 0186-grub-set-bootflag-Update-comment-about-running-as-ro.patch rename to 0135-grub-set-bootflag-Update-comment-about-running-as-ro.patch diff --git a/0187-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch b/0136-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch similarity index 100% rename from 0187-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch rename to 0136-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch diff --git a/0189-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch b/0137-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch similarity index 100% rename from 0189-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch rename to 0137-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch diff --git a/0192-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch b/0138-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch similarity index 100% rename from 0192-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch rename to 0138-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch diff --git a/0193-chainloader-Define-machine-types-for-RISC-V.patch b/0139-chainloader-Define-machine-types-for-RISC-V.patch similarity index 91% rename from 0193-chainloader-Define-machine-types-for-RISC-V.patch rename to 0139-chainloader-Define-machine-types-for-RISC-V.patch index 2ec7100..480db52 100644 --- a/0193-chainloader-Define-machine-types-for-RISC-V.patch +++ b/0139-chainloader-Define-machine-types-for-RISC-V.patch @@ -15,10 +15,10 @@ Signed-off-by: David Abdurachmanov 1 file changed, 4 insertions(+) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index f4ddbeda687..2c529f71471 100644 +index 47f5aa14817..ac8dfd40c61 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -316,6 +316,10 @@ static const grub_uint16_t machine_type __attribute__((__unused__)) = +@@ -333,6 +333,10 @@ static const grub_uint16_t machine_type __attribute__((__unused__)) = GRUB_PE32_MACHINE_I386; #elif defined(__ia64__) GRUB_PE32_MACHINE_IA64; diff --git a/0194-Add-start-symbol-for-RISC-V.patch b/0140-Add-start-symbol-for-RISC-V.patch similarity index 100% rename from 0194-Add-start-symbol-for-RISC-V.patch rename to 0140-Add-start-symbol-for-RISC-V.patch diff --git a/0198-bootstrap.conf-Force-autogen.sh-to-use-python3.patch b/0141-bootstrap.conf-Force-autogen.sh-to-use-python3.patch similarity index 86% rename from 0198-bootstrap.conf-Force-autogen.sh-to-use-python3.patch rename to 0141-bootstrap.conf-Force-autogen.sh-to-use-python3.patch index d63a24e..5c3b968 100644 --- a/0198-bootstrap.conf-Force-autogen.sh-to-use-python3.patch +++ b/0141-bootstrap.conf-Force-autogen.sh-to-use-python3.patch @@ -19,13 +19,13 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf -index 274c55a5568..5665c83351d 100644 +index 452f4d79b0d..03f10930230 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -84,7 +84,7 @@ cp -a INSTALL INSTALL.grub - - bootstrap_post_import_hook () { - set -e +@@ -93,7 +93,7 @@ bootstrap_post_import_hook () { + patch -d po -p3 \ + < "po/gettext-patches/$patchname.patch" + done - FROM_BOOTSTRAP=1 ./autogen.sh + PYTHON=python3 FROM_BOOTSTRAP=1 ./autogen.sh set +e # bootstrap expects this diff --git a/0141-strip-R-.note.gnu.property-at-more-places.patch b/0141-strip-R-.note.gnu.property-at-more-places.patch deleted file mode 100644 index d568422..0000000 --- a/0141-strip-R-.note.gnu.property-at-more-places.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 3 Aug 2018 15:07:23 -0400 -Subject: [PATCH] strip "-R .note.gnu.property" at more places. - -For whatever reason, sometimes I see: - - lzma_decompress.image: file format elf32-i386 - lzma_decompress.image - architecture: i386, flags 0x00000012: - EXEC_P, HAS_SYMS - start address 0x00008200 - - Program Header: - LOAD off 0x000000c0 vaddr 0x00008200 paddr 0x00008200 align 2**5 - filesz 0x00000b10 memsz 0x00000b10 flags rwx - LOAD off 0x00000bd0 vaddr 0x080480b4 paddr 0x080480b4 align 2**2 - filesz 0x0000001c memsz 0x0000001c flags r-- - NOTE off 0x00000bd0 vaddr 0x080480b4 paddr 0x080480b4 align 2**2 - filesz 0x0000001c memsz 0x0000001c flags r-- - STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**4 - filesz 0x00000000 memsz 0x00000000 flags rw- - - Sections: - Idx Name Size VMA LMA File off Algn - 0 .note.gnu.property 0000001c 080480b4 080480b4 00000bd0 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 1 .text 00000b10 00008200 00008200 000000c0 2**5 - CONTENTS, ALLOC, LOAD, CODE - SYMBOL TABLE: - 080480b4 l d .note.gnu.property 00000000 .note.gnu.property - 00008200 l d .text 00000000 .text - 00000000 l df *ABS* 00000000 startup_raw.S - ... - -Which just looks wrong no matter what to my eyes (seriously it's at -128M? Why?), and when we fail to strip it, we get: - -trillian:~/tmp/f29$ hexdump -C usr/lib/grub/i386-pc/lzma_decompress.img | tail -6 -00000b00 ff 45 e8 5a 83 c2 02 89 d1 e9 df fe ff ff 66 90 |.E.Z..........f.| -00000b10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -* -0803feb0 00 00 00 00 04 00 00 00 0c 00 00 00 05 00 00 00 |................| -0803fec0 47 4e 55 00 02 00 00 c0 04 00 00 00 03 00 00 00 |GNU.............| -0803fed0 - -Which is very very much not what we want. - -Cut it out. - -Signed-off-by: Peter Jones ---- - Makefile.am | 2 +- - gentpl.py | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Makefile.am b/Makefile.am -index bf9c1ba64c9..0d4dd7c2e90 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -209,7 +209,7 @@ pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub- - $(TARGET_CC) -o $@ $< -static -DTARGET_CHAINLOADER=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x7c00 -m32 - - pc-chainloader.bin: pc-chainloader.elf -- $(TARGET_OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; -+ $(TARGET_OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property $< $@; - - ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S - $(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -static -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0 -m32 -diff --git a/gentpl.py b/gentpl.py -index 95fe1a24d8a..32cf7456b72 100644 ---- a/gentpl.py -+++ b/gentpl.py -@@ -779,7 +779,7 @@ def image(defn, platform): - if test x$(TARGET_APPLE_LINKER) = x1; then \ - $(MACHO2IMG) $< $@; \ - else \ -- $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx $< $@; \ -+ $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx -R .note.gnu.property $< $@; \ - fi - """) - diff --git a/0199-efi-http-Export-fw-http-_path-variables-to-make-them.patch b/0142-efi-http-Export-fw-http-_path-variables-to-make-them.patch similarity index 95% rename from 0199-efi-http-Export-fw-http-_path-variables-to-make-them.patch rename to 0142-efi-http-Export-fw-http-_path-variables-to-make-them.patch index 1f85760..74183bc 100644 --- a/0199-efi-http-Export-fw-http-_path-variables-to-make-them.patch +++ b/0142-efi-http-Export-fw-http-_path-variables-to-make-them.patch @@ -25,10 +25,10 @@ Signed-off-by: Javier Martinez Canillas 2 files changed, 2 insertions(+) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index dcf48726d54..9bf6a8b231a 100644 +index 1c540fc8c26..b573be6650d 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c -@@ -142,6 +142,7 @@ grub_set_prefix_and_root (void) +@@ -143,6 +143,7 @@ grub_set_prefix_and_root (void) if (fw_path) { grub_env_set ("fw_path", fw_path); diff --git a/0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch b/0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch deleted file mode 100644 index a3c3213..0000000 --- a/0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 16 Aug 2018 11:08:11 -0400 -Subject: [PATCH] Make linux_arm_kernel_header.hdr_offset be at the right place - -The kernel in front of me (slightly edited to make objdump work) looks like: - -00000000 4d 5a 10 13 4d 5a 10 13 4d 5a 10 13 4d 5a 10 13 |MZ..MZ..MZ..MZ..| -00000010 4d 5a 10 13 4d 5a 10 13 4d 5a 10 13 00 00 a0 e1 |MZ..MZ..MZ......| -00000020 f6 03 00 ea 18 28 6f 01 00 00 00 00 00 32 74 00 |.....(o......2t.| -00000030 01 02 03 04 45 45 45 45 74 a2 00 00 40 00 00 00 |....EEEEt...@...| -00000040 50 45 00 00 4c 01 04 00 00 00 00 00 00 00 00 00 |PE..L...........| -00000050 00 00 00 00 90 00 06 03 0b 01 02 14 00 20 74 00 |............. t.| -00000060 00 14 00 00 00 00 00 00 b4 19 00 00 00 10 00 00 |................| -00000070 00 30 74 00 00 00 00 00 00 10 00 00 00 02 00 00 |.0t.............| -00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000090 00 44 74 00 00 10 00 00 00 00 00 00 0a 00 00 00 |.Dt.............| -000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -000000b0 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 |................| -000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -* - -(I don't know why the MZ header is there 7 times, but the offsets work out, so -it's merely a surprising distraction.) - -If linux_arm_kernel_header.reserved2 is 16 bytes, that means hdr_offset is -here: - -00000030 01 02 03 04 45 45 45 45 74 a2 00 00 40 00 00 00 |....EEEEt...@...| -00000040 50 45 00 00 4c 01 04 00 00 00 00 00 00 00 00 00 |PE..L...........| - ^^^^^^^^^^^ - -But it's supposed to be 4 bytes before that. - -This patch makes the reserved field be 3*32 instead of 4*32, and that means we -can find the PE header correcrtly at 0x40 by reading the value at 0x3c. - -Signed-off-by: Peter Jones ---- - grub-core/loader/efi/linux.c | 3 +++ - include/grub/arm/linux.h | 2 +- - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index 0622dfa48d4..b56ea0bc041 100644 ---- a/grub-core/loader/efi/linux.c -+++ b/grub-core/loader/efi/linux.c -@@ -79,7 +79,10 @@ grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, - offset = 512; - #endif - -+ grub_dprintf ("linux", "kernel_addr: %p handover_offset: %p params: %p\n", -+ kernel_addr, (void *)(grub_efi_uintn_t)handover_offset, kernel_params); - hf = (handover_func)((char *)kernel_addr + handover_offset + offset); -+ grub_dprintf ("linux", "handover_func() = %p\n", hf); - hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); - - return GRUB_ERR_BUG; -diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h -index 775297db869..b582f67f661 100644 ---- a/include/grub/arm/linux.h -+++ b/include/grub/arm/linux.h -@@ -31,7 +31,7 @@ struct linux_arm_kernel_header { - grub_uint32_t magic; - grub_uint32_t start; /* _start */ - grub_uint32_t end; /* _edata */ -- grub_uint32_t reserved2[4]; -+ grub_uint32_t reserved2[3]; - grub_uint32_t hdr_offset; - }; - diff --git a/0200-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch b/0143-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch similarity index 100% rename from 0200-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch rename to 0143-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch diff --git a/0201-efi-net-Allow-to-specify-a-port-number-in-addresses.patch b/0144-efi-net-Allow-to-specify-a-port-number-in-addresses.patch similarity index 100% rename from 0201-efi-net-Allow-to-specify-a-port-number-in-addresses.patch rename to 0144-efi-net-Allow-to-specify-a-port-number-in-addresses.patch diff --git a/0202-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch b/0145-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch similarity index 100% rename from 0202-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch rename to 0145-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch diff --git a/0146-EFI-more-debug-output-on-GOP-and-UGA-probing.patch b/0146-EFI-more-debug-output-on-GOP-and-UGA-probing.patch deleted file mode 100644 index 37d6f4d..0000000 --- a/0146-EFI-more-debug-output-on-GOP-and-UGA-probing.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 10 Sep 2018 13:01:24 -0400 -Subject: [PATCH] EFI: more debug output on GOP and UGA probing. - -Signed-off-by: Peter Jones ---- - grub-core/video/efi_gop.c | 8 +++++++- - grub-core/video/efi_uga.c | 4 ++-- - 2 files changed, 9 insertions(+), 3 deletions(-) - -diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c -index c9e40e8d4e9..be446f8d291 100644 ---- a/grub-core/video/efi_gop.c -+++ b/grub-core/video/efi_gop.c -@@ -71,7 +71,10 @@ check_protocol (void) - handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, - &graphics_output_guid, NULL, &num_handles); - if (!handles || num_handles == 0) -- return 0; -+ { -+ grub_dprintf ("video", "GOP: no handles\n"); -+ return 0; -+ } - - for (i = 0; i < num_handles; i++) - { -@@ -81,6 +84,7 @@ check_protocol (void) - grub_video_gop_iterate (check_protocol_hook, &have_usable_mode); - if (have_usable_mode) - { -+ grub_dprintf ("video", "GOP: found usable mode\n"); - grub_free (handles); - return 1; - } -@@ -89,6 +93,8 @@ check_protocol (void) - gop = 0; - gop_handle = 0; - -+ grub_dprintf ("video", "GOP: no usable mode\n"); -+ - return 0; - } - -diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c -index 97a607c01a5..e74d6c23500 100644 ---- a/grub-core/video/efi_uga.c -+++ b/grub-core/video/efi_uga.c -@@ -110,7 +110,7 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) - { - int i; - -- grub_dprintf ("fb", "Display controller: %d:%d.%d\nDevice id: %x\n", -+ grub_dprintf ("video", "Display controller: %d:%d.%d\nDevice id: %x\n", - grub_pci_get_bus (dev), grub_pci_get_device (dev), - grub_pci_get_function (dev), pciid); - addr += 8; -@@ -140,7 +140,7 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) - base64 <<= 32; - base64 |= (old_bar1 & GRUB_PCI_ADDR_MEM_MASK); - -- grub_dprintf ("fb", "%s(%d): 0x%" PRIxGRUB_UINT64_T "\n", -+ grub_dprintf ("video", "%s(%d): 0x%" PRIxGRUB_UINT64_T "\n", - ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ? - "VMEM" : "MMIO"), type == GRUB_PCI_ADDR_MEM_TYPE_64 ? i - 1 : i, - base64); diff --git a/0203-efi-net-Print-a-debug-message-if-parsing-the-address.patch b/0146-efi-net-Print-a-debug-message-if-parsing-the-address.patch similarity index 100% rename from 0203-efi-net-Print-a-debug-message-if-parsing-the-address.patch rename to 0146-efi-net-Print-a-debug-message-if-parsing-the-address.patch diff --git a/0147-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch b/0147-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch new file mode 100644 index 0000000..3dd525a --- /dev/null +++ b/0147-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Wed, 22 Apr 2020 12:41:52 +0200 +Subject: [PATCH] kern/term: Also accept F8 as a user interrupt key + +Make F8, which used to be the hotkey to show the Windows boot menu during +boot for a long long time, also interrupt sleeps / stop the menu countdown. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/kern/term.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c +index 14d59649832..4d61f4e9790 100644 +--- a/grub-core/kern/term.c ++++ b/grub-core/kern/term.c +@@ -144,9 +144,10 @@ grub_key_is_interrupt (int key) + /* + * ESC sometimes is the BIOS setup hotkey and may be hard to discover, also + * check F4, which was chosen because is not used as a hotkey to enter the +- * BIOS setup by any vendor. ++ * BIOS setup by any vendor. Also, F8 which was the key to get the Windows ++ * bootmenu for a long time. + */ +- if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F4) ++ if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F4 || key == GRUB_TERM_KEY_F8) + return 1; + + /* diff --git a/0210-efi-Set-image-base-address-before-jumping-to-the-PE-.patch b/0148-efi-Set-image-base-address-before-jumping-to-the-PE-.patch similarity index 82% rename from 0210-efi-Set-image-base-address-before-jumping-to-the-PE-.patch rename to 0148-efi-Set-image-base-address-before-jumping-to-the-PE-.patch index 3691587..336bcf1 100644 --- a/0210-efi-Set-image-base-address-before-jumping-to-the-PE-.patch +++ b/0148-efi-Set-image-base-address-before-jumping-to-the-PE-.patch @@ -21,15 +21,15 @@ and print the following warning message: EFI stub: ERROR: FIRMWARE BUG: efi_loaded_image_t::image_base has bogus value -Resolves: rhbz#1825411 +Resolves: rhbz#1814690 Signed-off-by: Javier Martinez Canillas --- - grub-core/loader/efi/linux.c | 12 ++++++++++++ - 1 file changed, 12 insertions(+) + grub-core/loader/efi/linux.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index b56ea0bc041..e09f824862b 100644 +index 0622dfa48d4..e8b9ecb17f6 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -72,6 +72,7 @@ grub_err_t @@ -40,7 +40,7 @@ index b56ea0bc041..e09f824862b 100644 handover_func hf; int offset = 0; -@@ -79,6 +80,17 @@ grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, +@@ -79,6 +80,19 @@ grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, offset = 512; #endif @@ -55,6 +55,8 @@ index b56ea0bc041..e09f824862b 100644 + else + grub_dprintf ("linux", "Loaded Image base address could not be set\n"); + - grub_dprintf ("linux", "kernel_addr: %p handover_offset: %p params: %p\n", - kernel_addr, (void *)(grub_efi_uintn_t)handover_offset, kernel_params); ++ grub_dprintf ("linux", "kernel_addr: %p handover_offset: %p params: %p\n", ++ kernel_addr, (void *)(grub_efi_uintn_t)handover_offset, kernel_params); hf = (handover_func)((char *)kernel_addr + handover_offset + offset); + hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); + diff --git a/0216-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch b/0149-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch similarity index 90% rename from 0216-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch rename to 0149-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch index ca125c6..747773d 100644 --- a/0216-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch +++ b/0149-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch @@ -18,10 +18,10 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c -index 1441c494d81..dbaeae46dfa 100644 +index 2052c36eaba..e287d042e6b 100644 --- a/grub-core/commands/tpm.c +++ b/grub-core/commands/tpm.c -@@ -49,7 +49,8 @@ grub_tpm_verify_init (grub_file_t io, +@@ -42,7 +42,8 @@ grub_tpm_verify_init (grub_file_t io, static grub_err_t grub_tpm_verify_write (void *context, void *buf, grub_size_t size) { @@ -31,7 +31,7 @@ index 1441c494d81..dbaeae46dfa 100644 } static grub_err_t -@@ -57,7 +58,6 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type) +@@ -50,7 +51,6 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type) { const char *prefix = NULL; char *description; @@ -39,7 +39,7 @@ index 1441c494d81..dbaeae46dfa 100644 switch (type) { -@@ -73,15 +73,15 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type) +@@ -66,15 +66,15 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type) } description = grub_malloc (grub_strlen (str) + grub_strlen (prefix) + 1); if (!description) diff --git a/0219-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch b/0150-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch similarity index 97% rename from 0219-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch rename to 0150-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch index fd68d09..825d0f7 100644 --- a/0219-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch +++ b/0150-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch @@ -26,7 +26,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 50b7798d6e5..e5b2736b0ce 100644 +index 6bc18d5aef5..15d40d6e35b 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -144,7 +144,7 @@ grub_linuxefi_unload (void) diff --git a/0220-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch b/0151-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch similarity index 80% rename from 0220-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch rename to 0151-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch index 1c5e599..97d2e06 100644 --- a/0220-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch +++ b/0151-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch @@ -16,22 +16,14 @@ path fails. Signed-off-by: Javier Martinez Canillas --- - grub-core/net/http.c | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) + grub-core/net/http.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index b52b558d631..598961afbb5 100644 +index b52b558d631..7f878b56157 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -501,13 +502,20 @@ http_open (struct grub_file *file, const char *filename) +@@ -501,13 +501,20 @@ http_open (struct grub_file *file, const char *filename) { grub_err_t err; struct http_data *data; diff --git a/0224-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch b/0152-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch similarity index 95% rename from 0224-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch rename to 0152-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch index 02528b5..1657d7a 100644 --- a/0224-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch +++ b/0152-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/efi/env.c b/grub-core/commands/efi/env.c -index a69079786aa..4838dac22e7 100644 +index cbd13e03e81..977edb6b065 100644 --- a/grub-core/commands/efi/env.c +++ b/grub-core/commands/efi/env.c @@ -149,6 +149,8 @@ grub_efi_load_env(grub_command_t cmd __attribute__ ((unused)), diff --git a/0251-efi-dhcp-fix-some-allocation-error-checking.patch b/0153-efi-dhcp-fix-some-allocation-error-checking.patch similarity index 100% rename from 0251-efi-dhcp-fix-some-allocation-error-checking.patch rename to 0153-efi-dhcp-fix-some-allocation-error-checking.patch diff --git a/0252-efi-http-fix-some-allocation-error-checking.patch b/0154-efi-http-fix-some-allocation-error-checking.patch similarity index 100% rename from 0252-efi-http-fix-some-allocation-error-checking.patch rename to 0154-efi-http-fix-some-allocation-error-checking.patch diff --git a/0253-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch b/0155-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch similarity index 100% rename from 0253-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch rename to 0155-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch diff --git a/0254-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch b/0156-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch similarity index 97% rename from 0254-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch rename to 0156-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch index 3f0b01d..95f7e20 100644 --- a/0254-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch +++ b/0156-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch @@ -13,7 +13,7 @@ Signed-off-by: Colin Watson 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index e5b2736b0ce..c0a98d152ff 100644 +index 15d40d6e35b..f992ceeef20 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -28,6 +28,8 @@ diff --git a/0257-linuxefi-fail-kernel-validation-without-shim-protoco.patch b/0157-linuxefi-fail-kernel-validation-without-shim-protoco.patch similarity index 90% rename from 0257-linuxefi-fail-kernel-validation-without-shim-protoco.patch rename to 0157-linuxefi-fail-kernel-validation-without-shim-protoco.patch index 3d04672..20fc786 100644 --- a/0257-linuxefi-fail-kernel-validation-without-shim-protoco.patch +++ b/0157-linuxefi-fail-kernel-validation-without-shim-protoco.patch @@ -23,7 +23,7 @@ Signed-off-by: Dimitri John Ledkov 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 8791b35b6fe..720eec075cd 100644 +index 70a0075ec5e..47f8cf0d84b 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -34,6 +34,7 @@ @@ -34,13 +34,13 @@ index 8791b35b6fe..720eec075cd 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -383,11 +384,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -363,11 +364,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); - rc = grub_linuxefi_secure_validate (kernel_addr, kernel_size); - if (rc < 0) -+ if (grub_efi_secure_boot ()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) { - grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); - goto fail; @@ -55,10 +55,10 @@ index 8791b35b6fe..720eec075cd 100644 pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 3dfa41bb49d..26f4fa9dc6a 100644 +index ac8dfd40c61..d41e8ea14a8 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -1083,6 +1083,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -1084,6 +1084,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), return 0; } @@ -67,7 +67,7 @@ index 3dfa41bb49d..26f4fa9dc6a 100644 fail: if (dev) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index e09f824862b..927d89a90d7 100644 +index e8b9ecb17f6..9260731c107 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -33,6 +33,7 @@ struct grub_efi_shim_lock @@ -79,7 +79,7 @@ index e09f824862b..927d89a90d7 100644 grub_linuxefi_secure_validate (void *data, grub_uint32_t size) { diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index c0a98d152ff..60ef7d12f07 100644 +index f992ceeef20..3cf0f9b330b 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -30,6 +30,7 @@ @@ -105,7 +105,7 @@ index c0a98d152ff..60ef7d12f07 100644 - rc = grub_linuxefi_secure_validate (kernel, filelen); - if (rc < 0) -+ if (grub_efi_secure_boot ()) ++ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) { - grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), - argv[0]); diff --git a/0260-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch b/0158-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch similarity index 88% rename from 0260-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch rename to 0158-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch index b7e55d3..0bd28c3 100644 --- a/0260-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch +++ b/0158-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch @@ -14,10 +14,10 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 5a5ebbfb1aa..2658a0cda4e 100644 +index 0b430489329..8f2f55c0079 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c -@@ -365,7 +365,7 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -329,7 +329,7 @@ grub_net_configure_by_dhcp_ack (const char *name, struct grub_net_network_level_interface *inter; int mask = -1; char server_ip[sizeof ("xxx.xxx.xxx.xxx")]; @@ -26,7 +26,7 @@ index 5a5ebbfb1aa..2658a0cda4e 100644 grub_uint8_t opt_len, overload = 0; const char *boot_file = 0, *server_name = 0; grub_size_t boot_file_len, server_name_len; -@@ -572,7 +572,7 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -505,7 +505,7 @@ grub_net_configure_by_dhcp_ack (const char *name, if (opt && opt_len) { grub_env_set_net_property (name, "vendor_class_identifier", (const char *) opt, opt_len); diff --git a/0261-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch b/0159-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch similarity index 100% rename from 0261-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch rename to 0159-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch diff --git a/0262-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch b/0160-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch similarity index 100% rename from 0262-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch rename to 0160-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch diff --git a/0160-Make-grub_strtol-end-pointers-have-safer-const-quali.patch b/0160-Make-grub_strtol-end-pointers-have-safer-const-quali.patch deleted file mode 100644 index 30c0828..0000000 --- a/0160-Make-grub_strtol-end-pointers-have-safer-const-quali.patch +++ /dev/null @@ -1,987 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 19 Oct 2018 13:41:48 -0400 -Subject: [PATCH] Make grub_strtol() "end" pointers have safer const - qualifiers. (v2) - -Currently the string functions grub_strtol(), grub_strtoul(), and -grub_strtoull() don't declare the "end" pointer in such a way as to -require the pointer itself or the character array to be immutable to the -implementation, nor does the C standard do so in its similar functions, -though it does require us not to change any of it. - -The typical declarations of these functions follow this pattern: - -long -strtol(const char * restrict nptr, char ** restrict endptr, int base); - -Much of the reason for this is historic, and a discussion of that -follows below, after the explanation of this change. (GRUB currently -does not include the "restrict" qualifiers, and we name the arguments a -bit differently.) - -The implementation is semantically required to treat the character array -as immutable, but such accidental modifications aren't stopped by the -compiler, and the semantics for both the callers and the implementation -of these functions are sometimes also helped by adding that requirement. - -This patch changes these declarations to follow this pattern instead: - -long -strtol(const char * restrict nptr, - const char ** const restrict endptr, - int base); - -This means that if any modification to these functions accidentally -introduces either an errant modification to the underlying character -array, or an accidental assignment to endptr rather than *endptr, the -compiler should generate an error. (The two uses of "restrict" in this -case basically mean strtol() isn't allowed to modify the character array -by going through *endptr, and endptr isn't allowed to point inside the -array.) - -It also means the typical use case changes to: - - char *s = ...; - const char *end; - long l; - - l = strtol(s, &end, 10); - -Or even: - - const char *p = str; - while (p && *p) { - long l = strtol(p, &p, 10); - ... - } - -This fixes 26 places where we discard our attempts at treating the data -safely by doing: - - const char *p = str; - long l; - - l = strtol(p, (char **)&ptr, 10); - -It also adds 5 places where we do: - - char *p = str; - while (p && *p) { - long l = strtol(p, (const char ** const)&p, 10); - ... - /* more calls that need p not to be pointer-to-const */ - } - -While moderately distasteful, this is a better problem to have. - -With one minor exception, I have tested that all of this compiles -without relevant warnings or errors, and that /much/ of it behaves -correctly, with gcc 9 using 'gcc -W -Wall -Wextra'. The one exception -is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea -how to build. - -Because the C standard defined type-qualifiers in a way that can be -confusing, in the past there's been a slow but fairly regular stream of -churn within our patches, which add and remove the const qualifier in many -of the users of these functions. This change should help avoid that in -the future, and in order to help ensure this, I've added an explanation -in misc.h so that when someone does get a compiler warning about a type -error, they have the fix at hand. - -The reason we don't have "const" in these calls in the standard is -purely anachronistic: C78 (de facto) did not have type qualifiers in the -syntax, and the "const" type qualifier was added for C89 (I think; it -may have been later). strtol() appears to date from 4.3BSD in 1986, -which means it could not be added to those functions in the standard -without breaking compatibility, which is usually avoided. - -The syntax chosen for type qualifiers is what has led to the churn -regarding usage of const, and is especially confusing on string -functions due to the lack of a string type. Quoting from C99, the -syntax is: - - declarator: - pointer[opt] direct-declarator - direct-declarator: - identifier - ( declarator ) - direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ] - ... - direct-declarator [ type-qualifier-list[opt] * ] - ... - pointer: - * type-qualifier-list[opt] - * type-qualifier-list[opt] pointer - type-qualifier-list: - type-qualifier - type-qualifier-list type-qualifier - ... - type-qualifier: - const - restrict - volatile - -So the examples go like: - -const char foo; // immutable object -const char *foo; // mutable pointer to object -char * const foo; // immutable pointer to mutable object -const char * const foo; // immutable pointer to immutable object -const char const * const foo; // XXX extra const keyword in the middle -const char * const * const foo; // immutable pointer to immutable - // pointer to immutable object -const char ** const foo; // immutable pointer to mutable pointer - // to immutable object - -Making const left-associative for * and right-associative for everything -else may not have been the best choice ever, but here we are, and the -inevitable result is people using trying to use const (as they should!), -putting it at the wrong place, fighting with the compiler for a bit, and -then either removing it or typecasting something in a bad way. I won't -go into describing restrict, but its syntax has exactly the same issue -as with const. - -Anyway, the last example above actually represents the *behavior* that's -required of strtol()-like functions, so that's our choice for the "end" -pointer. - -Signed-off-by: Peter Jones ---- - grub-core/commands/date.c | 3 ++- - grub-core/commands/i386/cmostest.c | 2 +- - grub-core/commands/i386/pc/play.c | 2 +- - grub-core/commands/i386/rdmsr.c | 2 +- - grub-core/commands/i386/wrmsr.c | 2 +- - grub-core/commands/password_pbkdf2.c | 2 +- - grub-core/commands/pcidump.c | 13 ++++++------- - grub-core/commands/regexp.c | 2 +- - grub-core/commands/setpci.c | 21 ++++++++++----------- - grub-core/commands/test.c | 2 +- - grub-core/commands/videoinfo.c | 2 +- - grub-core/disk/diskfilter.c | 3 ++- - grub-core/disk/lvm.c | 9 +++++---- - grub-core/efiemu/pnvram.c | 5 +++-- - grub-core/gfxmenu/gui_circular_progress.c | 2 +- - grub-core/gfxmenu/theme_loader.c | 2 +- - grub-core/kern/fs.c | 2 +- - grub-core/kern/misc.c | 10 ++++++---- - grub-core/kern/partition.c | 2 +- - grub-core/lib/arg.c | 2 +- - grub-core/lib/legacy_parse.c | 2 +- - grub-core/lib/syslinux_parse.c | 6 +++--- - grub-core/loader/i386/bsd.c | 6 +++--- - grub-core/loader/i386/linux.c | 2 +- - grub-core/loader/i386/pc/linux.c | 2 +- - grub-core/loader/i386/xen_fileXX.c | 2 +- - grub-core/mmap/mmap.c | 4 ++-- - grub-core/net/http.c | 4 ++-- - grub-core/net/net.c | 8 ++++---- - grub-core/normal/menu.c | 3 +-- - grub-core/osdep/aros/hostdisk.c | 2 +- - grub-core/osdep/devmapper/hostdisk.c | 2 +- - grub-core/script/execute.c | 6 +++--- - grub-core/term/serial.c | 2 +- - grub-core/term/terminfo.c | 2 +- - grub-core/tests/strtoull_test.c | 2 +- - util/grub-fstest.c | 2 +- - include/grub/misc.h | 24 +++++++++++++++++++++--- - 38 files changed, 96 insertions(+), 75 deletions(-) - -diff --git a/grub-core/commands/date.c b/grub-core/commands/date.c -index 8e1f41f141b..5cb4fafd454 100644 ---- a/grub-core/commands/date.c -+++ b/grub-core/commands/date.c -@@ -59,7 +59,8 @@ grub_cmd_date (grub_command_t cmd __attribute__ ((unused)), - - for (; argc; argc--, args++) - { -- char *p, c; -+ const char *p; -+ char c; - int m1, ofs, n, cur_mask; - - p = args[0]; -diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c -index c839b704dc5..9f6b56a2f0c 100644 ---- a/grub-core/commands/i386/cmostest.c -+++ b/grub-core/commands/i386/cmostest.c -@@ -27,7 +27,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - static grub_err_t - parse_args (int argc, char *argv[], int *byte, int *bit) - { -- char *rest; -+ const char *rest; - - if (argc != 1) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "address required"); -diff --git a/grub-core/commands/i386/pc/play.c b/grub-core/commands/i386/pc/play.c -index c8181310515..a980e46883c 100644 ---- a/grub-core/commands/i386/pc/play.c -+++ b/grub-core/commands/i386/pc/play.c -@@ -132,7 +132,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)), - } - else - { -- char *end; -+ const char *end; - unsigned tempo; - struct note note; - int i; -diff --git a/grub-core/commands/i386/rdmsr.c b/grub-core/commands/i386/rdmsr.c -index 15b9adfca67..46c4346da1b 100644 ---- a/grub-core/commands/i386/rdmsr.c -+++ b/grub-core/commands/i386/rdmsr.c -@@ -44,7 +44,7 @@ grub_cmd_msr_read (grub_extcmd_context_t ctxt, int argc, char **argv) - { - grub_uint32_t manufacturer[3], max_cpuid, a, b, c, features, addr; - grub_uint64_t value; -- char *ptr; -+ const char *ptr; - char buf[sizeof("1122334455667788")]; - - /* -diff --git a/grub-core/commands/i386/wrmsr.c b/grub-core/commands/i386/wrmsr.c -index 9c5e510eb44..fa76f5aed11 100644 ---- a/grub-core/commands/i386/wrmsr.c -+++ b/grub-core/commands/i386/wrmsr.c -@@ -37,7 +37,7 @@ grub_cmd_msr_write (grub_command_t cmd __attribute__ ((unused)), int argc, char - { - grub_uint32_t manufacturer[3], max_cpuid, a, b, c, features, addr; - grub_uint64_t value; -- char *ptr; -+ const char *ptr; - - /* - * The CPUID instruction should be used to determine whether MSRs -diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c -index da636e6217a..ab845d25eb3 100644 ---- a/grub-core/commands/password_pbkdf2.c -+++ b/grub-core/commands/password_pbkdf2.c -@@ -86,7 +86,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), - int argc, char **args) - { - grub_err_t err; -- char *ptr, *ptr2; -+ const char *ptr, *ptr2; - grub_uint8_t *ptro; - struct pbkdf2_password *pass; - -diff --git a/grub-core/commands/pcidump.c b/grub-core/commands/pcidump.c -index f99ad4a216f..f72628fce2d 100644 ---- a/grub-core/commands/pcidump.c -+++ b/grub-core/commands/pcidump.c -@@ -95,7 +95,7 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, - if (ctxt->state[0].set) - { - ptr = ctxt->state[0].arg; -- ctx.pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff); -+ ctx.pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff); - if (grub_errno == GRUB_ERR_BAD_NUMBER) - { - grub_errno = GRUB_ERR_NONE; -@@ -108,8 +108,7 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, - if (*ptr != ':') - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':'); - ptr++; -- ctx.pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff) -- << 16; -+ ctx.pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff) << 16; - if (grub_errno == GRUB_ERR_BAD_NUMBER) - grub_errno = GRUB_ERR_NONE; - else -@@ -121,10 +120,10 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, - if (ctxt->state[1].set) - { - const char *optr; -- -+ - ptr = ctxt->state[1].arg; - optr = ptr; -- ctx.bus = grub_strtoul (ptr, (char **) &ptr, 16); -+ ctx.bus = grub_strtoul (ptr, &ptr, 16); - if (grub_errno == GRUB_ERR_BAD_NUMBER) - { - grub_errno = GRUB_ERR_NONE; -@@ -138,7 +137,7 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':'); - ptr++; - optr = ptr; -- ctx.device = grub_strtoul (ptr, (char **) &ptr, 16); -+ ctx.device = grub_strtoul (ptr, &ptr, 16); - if (grub_errno == GRUB_ERR_BAD_NUMBER) - { - grub_errno = GRUB_ERR_NONE; -@@ -149,7 +148,7 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, - if (*ptr == '.') - { - ptr++; -- ctx.function = grub_strtoul (ptr, (char **) &ptr, 16); -+ ctx.function = grub_strtoul (ptr, &ptr, 16); - if (grub_errno) - return grub_errno; - ctx.check_function = 1; -diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c -index f00b184c81e..7c5c72fe460 100644 ---- a/grub-core/commands/regexp.c -+++ b/grub-core/commands/regexp.c -@@ -64,7 +64,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches, - { - int i; - char *p; -- char *q; -+ const char * q; - grub_err_t err; - unsigned long j; - -diff --git a/grub-core/commands/setpci.c b/grub-core/commands/setpci.c -index d5bc97d60b2..e966af080a6 100644 ---- a/grub-core/commands/setpci.c -+++ b/grub-core/commands/setpci.c -@@ -169,7 +169,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) - if (ctxt->state[0].set) - { - ptr = ctxt->state[0].arg; -- pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff); -+ pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff); - if (grub_errno == GRUB_ERR_BAD_NUMBER) - { - grub_errno = GRUB_ERR_NONE; -@@ -182,8 +182,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) - if (*ptr != ':') - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':'); - ptr++; -- pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff) -- << 16; -+ pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff) << 16; - if (grub_errno == GRUB_ERR_BAD_NUMBER) - grub_errno = GRUB_ERR_NONE; - else -@@ -197,10 +196,10 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) - if (ctxt->state[1].set) - { - const char *optr; -- -+ - ptr = ctxt->state[1].arg; - optr = ptr; -- bus = grub_strtoul (ptr, (char **) &ptr, 16); -+ bus = grub_strtoul (ptr, &ptr, 16); - if (grub_errno == GRUB_ERR_BAD_NUMBER) - { - grub_errno = GRUB_ERR_NONE; -@@ -214,7 +213,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':'); - ptr++; - optr = ptr; -- device = grub_strtoul (ptr, (char **) &ptr, 16); -+ device = grub_strtoul (ptr, &ptr, 16); - if (grub_errno == GRUB_ERR_BAD_NUMBER) - { - grub_errno = GRUB_ERR_NONE; -@@ -225,7 +224,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) - if (*ptr == '.') - { - ptr++; -- function = grub_strtoul (ptr, (char **) &ptr, 16); -+ function = grub_strtoul (ptr, &ptr, 16); - if (grub_errno) - return grub_errno; - check_function = 1; -@@ -253,7 +252,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) - if (i == ARRAY_SIZE (pci_registers)) - { - regsize = 0; -- regaddr = grub_strtoul (ptr, (char **) &ptr, 16); -+ regaddr = grub_strtoul (ptr, &ptr, 16); - if (grub_errno) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown register"); - } -@@ -270,7 +269,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) - if (*ptr == '+') - { - ptr++; -- regaddr += grub_strtoul (ptr, (char **) &ptr, 16); -+ regaddr += grub_strtoul (ptr, &ptr, 16); - if (grub_errno) - return grub_errno; - } -@@ -302,14 +301,14 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) - if (*ptr == '=') - { - ptr++; -- regwrite = grub_strtoul (ptr, (char **) &ptr, 16); -+ regwrite = grub_strtoul (ptr, &ptr, 16); - if (grub_errno) - return grub_errno; - write_mask = 0xffffffff; - if (*ptr == ':') - { - ptr++; -- write_mask = grub_strtoul (ptr, (char **) &ptr, 16); -+ write_mask = grub_strtoul (ptr, &ptr, 16); - if (grub_errno) - return grub_errno; - write_mask = 0xffffffff; -diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c -index 4e929e0452e..62d3fb3988f 100644 ---- a/grub-core/commands/test.c -+++ b/grub-core/commands/test.c -@@ -31,7 +31,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - - /* A simple implementation for signed numbers. */ - static int --grub_strtosl (char *arg, char **end, int base) -+grub_strtosl (char *arg, const char ** const end, int base) - { - if (arg[0] == '-') - return -grub_strtoul (arg + 1, end, base); -diff --git a/grub-core/commands/videoinfo.c b/grub-core/commands/videoinfo.c -index 4be8107d553..016a4d81835 100644 ---- a/grub-core/commands/videoinfo.c -+++ b/grub-core/commands/videoinfo.c -@@ -136,7 +136,7 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)), - ctx.height = ctx.width = ctx.depth = 0; - if (argc) - { -- char *ptr; -+ const char *ptr; - ptr = args[0]; - ctx.width = grub_strtoul (ptr, &ptr, 0); - if (grub_errno) -diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c -index 1a3eb6b8d77..3f264be77d1 100644 ---- a/grub-core/disk/diskfilter.c -+++ b/grub-core/disk/diskfilter.c -@@ -971,7 +971,8 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) - for (p = vgp->lvs; p; p = p->next) - { - int cur_num; -- char *num, *end; -+ char *num; -+ const char *end; - if (!p->fullname) - continue; - if (grub_strncmp (p->fullname, lv->fullname, len) != 0) -diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c -index 7b265c780c3..0cbd0dd1629 100644 ---- a/grub-core/disk/lvm.c -+++ b/grub-core/disk/lvm.c -@@ -38,7 +38,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - at the number. In case STR is not found, *P will be NULL and the - return value will be 0. */ - static grub_uint64_t --grub_lvm_getvalue (char **p, const char *str) -+grub_lvm_getvalue (const char ** const p, const char *str) - { - *p = grub_strstr (*p, str); - if (! *p) -@@ -63,12 +63,12 @@ grub_lvm_checkvalue (char **p, char *str, char *tmpl) - #endif - - static int --grub_lvm_check_flag (char *p, const char *str, const char *flag) -+grub_lvm_check_flag (const char *p, const char *str, const char *flag) - { - grub_size_t len_str = grub_strlen (str), len_flag = grub_strlen (flag); - while (1) - { -- char *q; -+ const char *q; - p = grub_strstr (p, str); - if (! p) - return 0; -@@ -105,7 +105,8 @@ grub_lvm_detect (grub_disk_t disk, - char buf[GRUB_LVM_LABEL_SIZE]; - char vg_id[GRUB_LVM_ID_STRLEN+1]; - char pv_id[GRUB_LVM_ID_STRLEN+1]; -- char *metadatabuf, *p, *q, *vgname; -+ char *metadatabuf, *vgname; -+ const char *p, *q; - struct grub_lvm_label_header *lh = (struct grub_lvm_label_header *) buf; - struct grub_lvm_pv_header *pvh; - struct grub_lvm_disk_locn *dlocn; -diff --git a/grub-core/efiemu/pnvram.c b/grub-core/efiemu/pnvram.c -index c5c3d4bd3d5..dd42bc69116 100644 ---- a/grub-core/efiemu/pnvram.c -+++ b/grub-core/efiemu/pnvram.c -@@ -39,7 +39,7 @@ static grub_size_t nvramsize; - - /* Parse signed value */ - static int --grub_strtosl (const char *arg, char **end, int base) -+grub_strtosl (const char *arg, const char ** const end, int base) - { - if (arg[0] == '-') - return -grub_strtoul (arg + 1, end, base); -@@ -120,7 +120,8 @@ nvram_set (void * data __attribute__ ((unused))) - grub_memset (nvram, 0, nvramsize); - FOR_SORTED_ENV (var) - { -- char *guid, *attr, *name, *varname; -+ const char *guid; -+ char *attr, *name, *varname; - struct efi_variable *efivar; - int len = 0; - int i; -diff --git a/grub-core/gfxmenu/gui_circular_progress.c b/grub-core/gfxmenu/gui_circular_progress.c -index 354dd7b73ee..7578bfbec92 100644 ---- a/grub-core/gfxmenu/gui_circular_progress.c -+++ b/grub-core/gfxmenu/gui_circular_progress.c -@@ -230,7 +230,7 @@ circprog_set_state (void *vself, int visible, int start, - static int - parse_angle (const char *value) - { -- char *ptr; -+ const char *ptr; - int angle; - - angle = grub_strtol (value, &ptr, 10); -diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c -index d6829bb5e90..eae83086bcc 100644 ---- a/grub-core/gfxmenu/theme_loader.c -+++ b/grub-core/gfxmenu/theme_loader.c -@@ -484,7 +484,7 @@ parse_proportional_spec (const char *value, signed *abs, grub_fixed_signed_t *pr - ptr++; - } - -- num = grub_strtoul (ptr, (char **) &ptr, 0); -+ num = grub_strtoul (ptr, &ptr, 0); - if (grub_errno) - return grub_errno; - if (sig) -diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c -index 2b85f4950bd..88d39360da0 100644 ---- a/grub-core/kern/fs.c -+++ b/grub-core/kern/fs.c -@@ -134,7 +134,7 @@ struct grub_fs_block - static grub_err_t - grub_fs_blocklist_open (grub_file_t file, const char *name) - { -- char *p = (char *) name; -+ const char *p = name; - unsigned num = 0; - unsigned i; - grub_disk_t disk = file->device->disk; -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 5c3899f0e5b..e21dd44c7cf 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -383,7 +383,8 @@ grub_isspace (int c) - } - - unsigned long --grub_strtoul (const char *str, char **end, int base) -+grub_strtoul (const char * restrict str, const char ** const restrict end, -+ int base) - { - unsigned long long num; - -@@ -400,7 +401,8 @@ grub_strtoul (const char *str, char **end, int base) - } - - unsigned long long --grub_strtoull (const char *str, char **end, int base) -+grub_strtoull (const char * restrict str, const char ** const restrict end, -+ int base) - { - unsigned long long num = 0; - int found = 0; -@@ -901,14 +903,14 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, - { - if (fmt[0] == '0') - zerofill = '0'; -- format1 = grub_strtoul (fmt, (char **) &fmt, 10); -+ format1 = grub_strtoul (fmt, &fmt, 10); - } - - if (*fmt == '.') - fmt++; - - if (grub_isdigit (*fmt)) -- format2 = grub_strtoul (fmt, (char **) &fmt, 10); -+ format2 = grub_strtoul (fmt, &fmt, 10); - - if (*fmt == '$') - { -diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c -index e499147cbcb..2c401b866c4 100644 ---- a/grub-core/kern/partition.c -+++ b/grub-core/kern/partition.c -@@ -126,7 +126,7 @@ grub_partition_probe (struct grub_disk *disk, const char *str) - while (*ptr && grub_isalpha (*ptr)) - ptr++; - partname_end = ptr; -- num = grub_strtoul (ptr, (char **) &ptr, 0) - 1; -+ num = grub_strtoul (ptr, &ptr, 0) - 1; - - curpart = 0; - /* Use the first partition map type found. */ -diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c -index fd7744a6ff6..ccc185017ee 100644 ---- a/grub-core/lib/arg.c -+++ b/grub-core/lib/arg.c -@@ -375,7 +375,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv, - - case ARG_TYPE_INT: - { -- char *tail; -+ const char * tail; - - grub_strtoull (option, &tail, 0); - if (tail == 0 || tail == option || *tail != '\0' || grub_errno) -diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c -index ef56150ac77..05719ab2ccb 100644 ---- a/grub-core/lib/legacy_parse.c -+++ b/grub-core/lib/legacy_parse.c -@@ -418,7 +418,7 @@ adjust_file (const char *in, grub_size_t len) - } - if (*comma != ',') - return grub_legacy_escape (in, len); -- part = grub_strtoull (comma + 1, (char **) &rest, 0); -+ part = grub_strtoull (comma + 1, &rest, 0); - if (rest[0] == ',' && rest[1] >= 'a' && rest[1] <= 'z') - { - subpart = rest[1] - 'a'; -diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c -index 4afa99279a2..de9fda06f52 100644 ---- a/grub-core/lib/syslinux_parse.c -+++ b/grub-core/lib/syslinux_parse.c -@@ -1062,7 +1062,7 @@ write_entry (struct output_buffer *outbuf, - if (ptr[0] == 'h' && ptr[1] == 'd') - { - is_fd = 0; -- devn = grub_strtoul (ptr + 2, &ptr, 0); -+ devn = grub_strtoul (ptr + 2, (const char **)&ptr, 0); - continue; - } - if (grub_strncasecmp (ptr, "file=", 5) == 0) -@@ -1086,12 +1086,12 @@ write_entry (struct output_buffer *outbuf, - if (ptr[0] == 'f' && ptr[1] == 'd') - { - is_fd = 1; -- devn = grub_strtoul (ptr + 2, &ptr, 0); -+ devn = grub_strtoul (ptr + 2, (const char **)&ptr, 0); - continue; - } - if (grub_isdigit (ptr[0])) - { -- part = grub_strtoul (ptr, &ptr, 0); -+ part = grub_strtoul (ptr, (const char **)&ptr, 0); - continue; - } - /* FIXME: isolinux, ntldr, cmldr, *dos, seg, hide -diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c -index 5b9b92d6ba5..50cca304fd0 100644 ---- a/grub-core/loader/i386/bsd.c -+++ b/grub-core/loader/i386/bsd.c -@@ -1616,7 +1616,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "unknown disk type name"); - -- unit = grub_strtoul (arg, (char **) &arg, 10); -+ unit = grub_strtoul (arg, &arg, 10); - if (! (arg && *arg >= 'a' && *arg <= 'z')) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only device specifications of form " -@@ -1634,7 +1634,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) - if (ctxt->state[OPENBSD_SERIAL_ARG].set) - { - struct grub_openbsd_bootarg_console serial; -- char *ptr; -+ const char *ptr; - unsigned port = 0; - unsigned speed = 9600; - -@@ -1736,7 +1736,7 @@ grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) - if (ctxt->state[NETBSD_SERIAL_ARG].set) - { - struct grub_netbsd_btinfo_serial serial; -- char *ptr; -+ const char *ptr; - - grub_memset (&serial, 0, sizeof (serial)); - grub_strcpy (serial.devname, "com"); -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 376c726928a..201e6597c6d 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -954,7 +954,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - #endif /* GRUB_MACHINE_PCBIOS */ - if (grub_memcmp (argv[i], "mem=", 4) == 0) - { -- char *val = argv[i] + 4; -+ const char *val = argv[i] + 4; - - linux_mem_size = grub_strtoul (val, &val, 0); - -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index fe3e1d41d09..0bf0e13d647 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -272,7 +272,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - else if (grub_memcmp (argv[i], "mem=", 4) == 0) - { -- char *val = argv[i] + 4; -+ const char *val = argv[i] + 4; - - linux_mem_size = grub_strtoul (val, &val, 0); - -diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c -index 6329ec01038..27afcaacbce 100644 ---- a/grub-core/loader/i386/xen_fileXX.c -+++ b/grub-core/loader/i386/xen_fileXX.c -@@ -25,7 +25,7 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, - grub_off_t off, grub_size_t sz) - { - char *buf; -- char *ptr; -+ const char *ptr; - int has_paddr = 0; - - grub_errno = GRUB_ERR_NONE; -diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c -index 6a31cbae325..b569cb23b5a 100644 ---- a/grub-core/mmap/mmap.c -+++ b/grub-core/mmap/mmap.c -@@ -423,7 +423,7 @@ static grub_err_t - grub_cmd_badram (grub_command_t cmd __attribute__ ((unused)), - int argc, char **args) - { -- char * str; -+ const char *str; - struct badram_entry entry; - - if (argc != 1) -@@ -465,7 +465,7 @@ static grub_uint64_t - parsemem (const char *str) - { - grub_uint64_t ret; -- char *ptr; -+ const char *ptr; - - ret = grub_strtoul (str, &ptr, 0); - -diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index c9c59690a98..b52b558d631 100644 ---- a/grub-core/net/http.c -+++ b/grub-core/net/http.c -@@ -110,7 +110,7 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) - return GRUB_ERR_NONE; - } - ptr += sizeof ("HTTP/1.1 ") - 1; -- code = grub_strtoul (ptr, &ptr, 10); -+ code = grub_strtoul (ptr, (const char **)&ptr, 10); - if (grub_errno) - return grub_errno; - switch (code) -@@ -137,7 +137,7 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) - == 0 && !data->size_recv) - { - ptr += sizeof ("Content-Length: ") - 1; -- file->size = grub_strtoull (ptr, &ptr, 10); -+ file->size = grub_strtoull (ptr, (const char **)&ptr, 10); - data->size_recv = 1; - return GRUB_ERR_NONE; - } -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 27a0a1d6961..aa56393e1c4 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -411,7 +411,7 @@ parse_ip (const char *val, grub_uint32_t *ip, const char **rest) - for (i = 0; i < 4; i++) - { - unsigned long t; -- t = grub_strtoul (ptr, (char **) &ptr, 0); -+ t = grub_strtoul (ptr, &ptr, 0); - if (grub_errno) - { - grub_errno = GRUB_ERR_NONE; -@@ -465,7 +465,7 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) - ptr++; - continue; - } -- t = grub_strtoul (ptr, (char **) &ptr, 16); -+ t = grub_strtoul (ptr, &ptr, 16); - if (grub_errno) - { - grub_errno = GRUB_ERR_NONE; -@@ -577,7 +577,7 @@ grub_net_resolve_net_address (const char *name, - addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - if (*rest == '/') - { -- addr->ipv4.masksize = grub_strtoul (rest + 1, (char **) &rest, 0); -+ addr->ipv4.masksize = grub_strtoul (rest + 1, &rest, 0); - if (!grub_errno && *rest == 0) - return GRUB_ERR_NONE; - grub_errno = GRUB_ERR_NONE; -@@ -593,7 +593,7 @@ grub_net_resolve_net_address (const char *name, - addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; - if (*rest == '/') - { -- addr->ipv6.masksize = grub_strtoul (rest + 1, (char **) &rest, 0); -+ addr->ipv6.masksize = grub_strtoul (rest + 1, &rest, 0); - if (!grub_errno && *rest == 0) - return GRUB_ERR_NONE; - grub_errno = GRUB_ERR_NONE; -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 046a1fb2c84..37d753d8081 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -194,8 +194,7 @@ menuentry_eq (const char *id, const char *spec) - static int - get_and_remove_first_entry_number (grub_menu_t menu, const char *name) - { -- const char *val; -- char *tail; -+ const char *val, *tail; - int entry; - int sz = 0; - -diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hostdisk.c -index 2be654ca3bd..3b2c9de2496 100644 ---- a/grub-core/osdep/aros/hostdisk.c -+++ b/grub-core/osdep/aros/hostdisk.c -@@ -194,7 +194,7 @@ grub_util_fd_open (const char *dev, int flg) - p1 = dev + strlen (dev); - else - { -- unit = grub_strtoul (p1 + 1, (char **) &p2, 16); -+ unit = grub_strtoul (p1 + 1, &p2, 16); - if (p2 && *p2 == '/') - flags = grub_strtoul (p2 + 1, 0, 16); - } -diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/hostdisk.c -index a697bcb4d8d..a8afc0c9408 100644 ---- a/grub-core/osdep/devmapper/hostdisk.c -+++ b/grub-core/osdep/devmapper/hostdisk.c -@@ -113,7 +113,7 @@ grub_util_get_dm_node_linear_info (dev_t dev, - void *next = NULL; - uint64_t length, start; - char *target, *params; -- char *ptr; -+ const char *ptr; - int major = 0, minor = 0; - int first = 1; - grub_disk_addr_t partstart = 0; -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index ba38b5e8aef..c6d2c365c9a 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -146,7 +146,7 @@ replace_scope (struct grub_script_scope *new_scope) - grub_err_t - grub_script_break (grub_command_t cmd, int argc, char *argv[]) - { -- char *p = 0; -+ const char *p = NULL; - unsigned long count; - - if (argc == 0) -@@ -178,7 +178,7 @@ grub_err_t - grub_script_shift (grub_command_t cmd __attribute__((unused)), - int argc, char *argv[]) - { -- char *p = 0; -+ const char *p = NULL; - unsigned long n = 0; - - if (! scope) -@@ -239,7 +239,7 @@ grub_err_t - grub_script_return (grub_command_t cmd __attribute__((unused)), - int argc, char *argv[]) - { -- char *p; -+ const char *p = NULL; - unsigned long n; - - if (! scope || argc > 1) -diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c -index db80b3ba0fb..f9271b09239 100644 ---- a/grub-core/term/serial.c -+++ b/grub-core/term/serial.c -@@ -269,7 +269,7 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args) - - if (state[OPTION_BASE_CLOCK].set) - { -- char *ptr; -+ const char *ptr; - config.base_clock = grub_strtoull (state[OPTION_BASE_CLOCK].arg, &ptr, 0); - if (grub_errno) - return grub_errno; -diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c -index 29df35e6d20..537a5c0cb0b 100644 ---- a/grub-core/term/terminfo.c -+++ b/grub-core/term/terminfo.c -@@ -737,7 +737,7 @@ grub_cmd_terminfo (grub_extcmd_context_t ctxt, int argc, char **args) - - if (state[OPTION_GEOMETRY].set) - { -- char *ptr = state[OPTION_GEOMETRY].arg; -+ const char *ptr = state[OPTION_GEOMETRY].arg; - w = grub_strtoul (ptr, &ptr, 0); - if (grub_errno) - return grub_errno; -diff --git a/grub-core/tests/strtoull_test.c b/grub-core/tests/strtoull_test.c -index 7da615ff33e..5488ab26b43 100644 ---- a/grub-core/tests/strtoull_test.c -+++ b/grub-core/tests/strtoull_test.c -@@ -25,7 +25,7 @@ static void - strtoull_testcase (const char *input, int base, unsigned long long expected, - int num_digits, grub_err_t error) - { -- char *output; -+ const char *output; - unsigned long long value; - grub_errno = 0; - value = grub_strtoull(input, &output, base); -diff --git a/util/grub-fstest.c b/util/grub-fstest.c -index 88f9c5d4ad8..39bad1f432f 100644 ---- a/util/grub-fstest.c -+++ b/util/grub-fstest.c -@@ -538,7 +538,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; - static error_t - argp_parser (int key, char *arg, struct argp_state *state) - { -- char *p; -+ const char *p; - - switch (key) - { -diff --git a/include/grub/misc.h b/include/grub/misc.h -index 960097fbd06..998e47e0ccf 100644 ---- a/include/grub/misc.h -+++ b/include/grub/misc.h -@@ -288,11 +288,29 @@ grub_strncasecmp (const char *s1, const char *s2, grub_size_t n) - - (int) grub_tolower ((grub_uint8_t) *s2); - } - --unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base); --unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base); -+/* -+ * Note that these differ from the C standard's definitions of strtol, -+ * strtoul(), and strtoull() by the addition of two const qualifiers on the end -+ * pointer, which make the declaration match the *semantic* requirements of -+ * their behavior. This means that instead of: -+ * -+ * char *s = "1234 abcd"; -+ * char *end; -+ * unsigned long l; -+ * -+ * l = grub_strtoul(s, &end, 10); -+ * -+ * We must one of: -+ * -+ * const char *end; -+ * ... or ... -+ * l = grub_strtoul(s, (const char ** const)&end, 10); -+ */ -+unsigned long EXPORT_FUNC(grub_strtoul) (const char * restrict str, const char ** const restrict end, int base); -+unsigned long long EXPORT_FUNC(grub_strtoull) (const char * restrict str, const char ** const restrict end, int base); - - static inline long --grub_strtol (const char *str, char **end, int base) -+grub_strtol (const char * restrict str, const char ** const restrict end, int base) - { - int negative = 0; - unsigned long long magnitude; diff --git a/0263-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch b/0161-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch similarity index 100% rename from 0263-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch rename to 0161-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch diff --git a/0264-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch b/0162-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch similarity index 100% rename from 0264-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch rename to 0162-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch diff --git a/0266-Add-systemd-integration-scripts-to-make-systemctl-re.patch b/0163-Add-systemd-integration-scripts-to-make-systemctl-re.patch similarity index 97% rename from 0266-Add-systemd-integration-scripts-to-make-systemctl-re.patch rename to 0163-Add-systemd-integration-scripts-to-make-systemctl-re.patch index faf5139..130dc77 100644 --- a/0266-Add-systemd-integration-scripts-to-make-systemctl-re.patch +++ b/0163-Add-systemd-integration-scripts-to-make-systemctl-re.patch @@ -65,10 +65,10 @@ Signed-off-by: Hans de Goede create mode 100644 util/systemd/systemd-integration.sh.in diff --git a/Makefile.util.def b/Makefile.util.def -index f3a699691bf..dc8d1790ea5 100644 +index 11ab2d6fad1..e1242f54022 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -469,6 +469,12 @@ script = { +@@ -470,6 +470,12 @@ script = { installdir = grubconf; }; @@ -81,7 +81,7 @@ index f3a699691bf..dc8d1790ea5 100644 script = { name = '01_users'; common = util/grub.d/01_users.in; -@@ -568,6 +574,27 @@ script = { +@@ -569,6 +575,27 @@ script = { installdir = grubconf; }; @@ -110,7 +110,7 @@ index f3a699691bf..dc8d1790ea5 100644 mansection = 1; name = grub-mkrescue; diff --git a/conf/Makefile.common b/conf/Makefile.common -index 87c1f0e809b..6b85eb394ce 100644 +index 0647c53b916..9fe5863b2d9 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -63,8 +63,11 @@ CCASFLAGS_LIBRARY = $(UTILS_CCASFLAGS) @@ -125,7 +125,7 @@ index 87c1f0e809b..6b85eb394ce 100644 CFLAGS_GNULIB = -Wno-undef -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Werror=trampolines -fno-trampolines CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib -@@ -119,6 +122,9 @@ noinst_LIBRARIES = +@@ -121,6 +124,9 @@ noinst_LIBRARIES = dist_noinst_DATA = platform_SCRIPTS = platform_PROGRAMS = diff --git a/0267-systemd-integration.sh-Also-set-old-menu_show_once-g.patch b/0164-systemd-integration.sh-Also-set-old-menu_show_once-g.patch similarity index 100% rename from 0267-systemd-integration.sh-Also-set-old-menu_show_once-g.patch rename to 0164-systemd-integration.sh-Also-set-old-menu_show_once-g.patch diff --git a/0302-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch b/0165-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch similarity index 99% rename from 0302-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch rename to 0165-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch index 047b07b..c338840 100644 --- a/0302-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch +++ b/0165-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch @@ -29,7 +29,7 @@ Signed-off-by: Renaud Métrich 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c -index f0a986eb176..69d99b61df5 100644 +index 597111077bd..26014382608 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -135,20 +135,28 @@ query_mode (void) diff --git a/0166-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch b/0166-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch deleted file mode 100644 index 2cef9b9..0000000 --- a/0166-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Masayoshi Mizuma -Date: Tue, 18 Dec 2018 21:27:45 -0500 -Subject: [PATCH] Fix the looking up grub.cfg-XXX while tftp booting. - -Currently, grub doesn't look up grub.cfg-UUID, grub.cfg-MAC and grub.cfg-IP -while the boot is from tftp. That is because the uuid size is got by -grub_snprintf(, 0, ,), but the grub_snprintf() always returns 0, -so grub judges there's no available uuid in the client and give up -the looking up grub.cfg-XXX. - -This issue can be fixed by changing grub_snprintf(, 0, ,) behaivior -to like as snprintf() from glibc, however, somewhere may expect -such argument as the error, so it's risky. - -Let's use sizeof() and grub_strlen() to calculate the uuid size -instead of grub_snprintf(). - -Resolves: rhbz#1658500 ---- - grub-core/net/net.c | 8 +++----- - 1 file changed, 3 insertions(+), 5 deletions(-) - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index aa56393e1c4..15073dde1c4 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -1942,11 +1942,9 @@ grub_net_search_configfile (char *config) - char *client_uuid_var; - grub_size_t client_uuid_var_size; - -- client_uuid_var_size = grub_snprintf (NULL, 0, -- "net_%s_clientuuid", inf->name); -- if (client_uuid_var_size <= 0) -- continue; -- client_uuid_var_size += 1; -+ client_uuid_var_size = sizeof ("net_") + grub_strlen (inf->name) + -+ sizeof ("_clientuuid") + 1; -+ - client_uuid_var = grub_malloc(client_uuid_var_size); - if (!client_uuid_var) - continue; diff --git a/0269-grub-install-disable-support-for-EFI-platforms.patch b/0166-grub-install-disable-support-for-EFI-platforms.patch similarity index 96% rename from 0269-grub-install-disable-support-for-EFI-platforms.patch rename to 0166-grub-install-disable-support-for-EFI-platforms.patch index e5104bf..e3cf2ec 100644 --- a/0269-grub-install-disable-support-for-EFI-platforms.patch +++ b/0166-grub-install-disable-support-for-EFI-platforms.patch @@ -26,7 +26,7 @@ Signed-off-by: Jan Hlavac 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/util/grub-install.c b/util/grub-install.c -index dddb7576c97..b3f5e414052 100644 +index 1e47491bc21..ffac91c9a24 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -899,6 +899,22 @@ main (int argc, char *argv[]) @@ -82,10 +82,10 @@ index dddb7576c97..b3f5e414052 100644 { grub_fs_t fs; diff --git a/docs/grub.texi b/docs/grub.texi -index 495462b8e48..085b9974cc5 100644 +index 67bf8523ccb..75b22231f35 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -6293,6 +6293,13 @@ grub2-install @var{install_device} +@@ -6506,6 +6506,13 @@ grub2-install @var{install_device} The device name @var{install_device} is an OS device name or a GRUB device name. diff --git a/0270-New-with-debug-timestamps-configure-flag-to-prepend-.patch b/0167-New-with-debug-timestamps-configure-flag-to-prepend-.patch similarity index 92% rename from 0270-New-with-debug-timestamps-configure-flag-to-prepend-.patch rename to 0167-New-with-debug-timestamps-configure-flag-to-prepend-.patch index e3d09bc..ff2841e 100644 --- a/0270-New-with-debug-timestamps-configure-flag-to-prepend-.patch +++ b/0167-New-with-debug-timestamps-configure-flag-to-prepend-.patch @@ -15,10 +15,10 @@ Signed-off-by: Renaud Métrich 3 files changed, 39 insertions(+) diff --git a/configure.ac b/configure.ac -index 5d3316185da..d150a2e4a9c 100644 +index 2e4b12adad3..7b11fae0c3d 100644 --- a/configure.ac +++ b/configure.ac -@@ -1555,6 +1555,17 @@ else +@@ -1613,6 +1613,17 @@ else fi AC_SUBST([BOOT_TIME_STATS]) @@ -36,7 +36,7 @@ index 5d3316185da..d150a2e4a9c 100644 AC_ARG_ENABLE([grub-emu-sdl], [AS_HELP_STRING([--enable-grub-emu-sdl], [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])]) -@@ -2142,6 +2153,7 @@ AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1]) +@@ -2200,6 +2211,7 @@ AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1]) AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes]) AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1]) AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1]) @@ -44,7 +44,7 @@ index 5d3316185da..d150a2e4a9c 100644 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes]) -@@ -2237,6 +2249,12 @@ else +@@ -2295,6 +2307,12 @@ else echo With boot time statistics: No fi @@ -58,7 +58,7 @@ index 5d3316185da..d150a2e4a9c 100644 echo efiemu runtime: Yes else diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index dc5e10b651a..bc23945a3c2 100644 +index 578bf51a5fc..9f54b6b7d2d 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -25,6 +25,9 @@ @@ -71,7 +71,7 @@ index dc5e10b651a..bc23945a3c2 100644 union printf_arg { -@@ -191,9 +194,26 @@ grub_real_dprintf (const char *file, const int line, const char *condition, +@@ -192,9 +195,26 @@ grub_real_dprintf (const char *file, const int line, const char *condition, const char *fmt, ...) { va_list args; diff --git a/0167-Try-to-set-fPIE-and-friends-on-libgnu.a.patch b/0167-Try-to-set-fPIE-and-friends-on-libgnu.a.patch deleted file mode 100644 index 837da31..0000000 --- a/0167-Try-to-set-fPIE-and-friends-on-libgnu.a.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 12 Jul 2019 17:45:51 +0200 -Subject: [PATCH] Try to set -fPIE and friends on libgnu.a - -In order to make sure UTIL_CFLAGS and UTIL_LDFLAGS can correctly get --Wl,-z,relro,-z,now , we need everything going in them to be built with at -least -fPIC (and preferably -fPIE) wherever we can, or else we get relocations -in some component object that can't be used with the link type that's being -used for the final ELF object. - -So this makes sure libgnu.a gets built with HOST_CFLAGS and HOST_LDFLAGS, -which are what is later used to define UTIL_CFLAGS and UTIL_LDFLAGS, and -includes -fPIE. - -Fixes an rpmdiff check. - -Related: rhbz#1658500 - -Signed-off-by: Peter Jones -[javierm: replace from bootstrap instead patching generated Makefile.am] -Signed-off-by: Javier Martinez Canillas ---- - bootstrap.conf | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/bootstrap.conf b/bootstrap.conf -index 8804d5beb89..29a6a3e90e2 100644 ---- a/bootstrap.conf -+++ b/bootstrap.conf -@@ -82,6 +82,9 @@ bootstrap_post_import_hook () { - patch -d grub-core/lib/gnulib -p2 \ - < "grub-core/lib/gnulib-patches/$patchname.patch" - done -+ for flagvar in CPPFLAGS CFLAGS; do -+ sed -i -e "s/^AM_$flagvar =/AM_$flagvar = \$(HOST_$flagvar)/" grub-core/lib/gnulib/Makefile.am -+ done - FROM_BOOTSTRAP=1 ./autogen.sh - set +e # bootstrap expects this - } diff --git a/0271-Added-debug-statements-to-grub_disk_open-and-grub_di.patch b/0168-Added-debug-statements-to-grub_disk_open-and-grub_di.patch similarity index 97% rename from 0271-Added-debug-statements-to-grub_disk_open-and-grub_di.patch rename to 0168-Added-debug-statements-to-grub_disk_open-and-grub_di.patch index 9497840..cbb1a38 100644 --- a/0271-Added-debug-statements-to-grub_disk_open-and-grub_di.patch +++ b/0168-Added-debug-statements-to-grub_disk_open-and-grub_di.patch @@ -13,7 +13,7 @@ Signed-off-by: Renaud Métrich 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/disk.c b/grub-core/kern/disk.c -index ffb09c8eefb..141b40de473 100644 +index e1b0e073e09..05a28ab1429 100644 --- a/grub-core/kern/disk.c +++ b/grub-core/kern/disk.c @@ -285,6 +285,8 @@ grub_disk_open (const char *name) diff --git a/0168-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch b/0168-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch deleted file mode 100644 index 21d242e..0000000 --- a/0168-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 11 Feb 2019 15:14:10 +0100 -Subject: [PATCH] Don't make grub_strtoull() print an error if no conversion is - performed - -Callers can check if grub_errno was set to GRUB_ERR_BAD_NUMBER, so there's -no need to print an error if a conversion couldn't be performed. This just -pollutes the output with noisy error messages. - -Resolves: rhbz#1674512 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/kern/misc.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 18a7dbf4cd7..87afb43cd55 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -475,8 +475,7 @@ grub_strtoull (const char * restrict str, const char ** const restrict end, - - if (! found) - { -- grub_error (GRUB_ERR_BAD_NUMBER, -- N_("unrecognized number")); -+ grub_errno = GRUB_ERR_BAD_NUMBER; - return 0; - } - diff --git a/0169-Fix-the-type-of-grub_efi_status_t.patch b/0169-Fix-the-type-of-grub_efi_status_t.patch deleted file mode 100644 index fba3f3d..0000000 --- a/0169-Fix-the-type-of-grub_efi_status_t.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Mar 2019 13:06:06 -0400 -Subject: [PATCH] Fix the type of grub_efi_status_t - -Currently, in some builds with some checkers, we see: - -1. grub-core/disk/efi/efidisk.c:601: error[shiftTooManyBitsSigned]: Shifting signed 64-bit value by 63 bits is undefined behaviour - -This is because grub_efi_status_t is defined as grub_efi_intn_t, which is -signed, and shifting into the sign bit is not defined behavior. UEFI fixed -this in the spec in 2.3: - -2.3 | Change the defined type of EFI_STATUS from INTN to UINTN | May 7, 2009 - -And the current EDK2 code has: -MdePkg/Include/Base.h-// -MdePkg/Include/Base.h-// Status codes common to all execution phases -MdePkg/Include/Base.h-// -MdePkg/Include/Base.h:typedef UINTN RETURN_STATUS; -MdePkg/Include/Base.h- -MdePkg/Include/Base.h-/** -MdePkg/Include/Base.h- Produces a RETURN_STATUS code with the highest bit set. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h- @param StatusCode The status code value to convert into a warning code. -MdePkg/Include/Base.h- StatusCode must be in the range 0x00000000..0x7FFFFFFF. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h- @return The value specified by StatusCode with the highest bit set. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h-**/ -MdePkg/Include/Base.h-#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode))) -MdePkg/Include/Base.h- -MdePkg/Include/Base.h-/** -MdePkg/Include/Base.h- Produces a RETURN_STATUS code with the highest bit clear. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h- @param StatusCode The status code value to convert into a warning code. -MdePkg/Include/Base.h- StatusCode must be in the range 0x00000000..0x7FFFFFFF. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h- @return The value specified by StatusCode with the highest bit clear. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h-**/ -MdePkg/Include/Base.h-#define ENCODE_WARNING(StatusCode) ((RETURN_STATUS)(StatusCode)) -MdePkg/Include/Base.h- -MdePkg/Include/Base.h-/** -MdePkg/Include/Base.h- Returns TRUE if a specified RETURN_STATUS code is an error code. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h- This function returns TRUE if StatusCode has the high bit set. Otherwise, FALSE is returned. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h- @param StatusCode The status code value to evaluate. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h- @retval TRUE The high bit of StatusCode is set. -MdePkg/Include/Base.h- @retval FALSE The high bit of StatusCode is clear. -MdePkg/Include/Base.h- -MdePkg/Include/Base.h-**/ -MdePkg/Include/Base.h-#define RETURN_ERROR(StatusCode) (((INTN)(RETURN_STATUS)(StatusCode)) < 0) -... -Uefi/UefiBaseType.h:typedef RETURN_STATUS EFI_STATUS; - -This patch makes grub's implementation match the Edk2 declaration with regards -to the signedness of the type. - -Signed-off-by: Peter Jones ---- - include/grub/efi/api.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 2ed9c26a450..dec7b06083e 100644 ---- a/include/grub/efi/api.h -+++ b/include/grub/efi/api.h -@@ -536,7 +536,7 @@ typedef grub_uint64_t grub_efi_uint64_t; - typedef grub_uint8_t grub_efi_char8_t; - typedef grub_uint16_t grub_efi_char16_t; - --typedef grub_efi_intn_t grub_efi_status_t; -+typedef grub_efi_uintn_t grub_efi_status_t; - /* Make grub_efi_status_t reasonably printable. */ - #if GRUB_CPU_SIZEOF_VOID_P == 8 - #define PRIxGRUB_EFI_STATUS "lx" diff --git a/0272-Introduce-function-grub_debug_is_enabled-void-return.patch b/0169-Introduce-function-grub_debug_is_enabled-void-return.patch similarity index 87% rename from 0272-Introduce-function-grub_debug_is_enabled-void-return.patch rename to 0169-Introduce-function-grub_debug_is_enabled-void-return.patch index 5424858..4e4718b 100644 --- a/0272-Introduce-function-grub_debug_is_enabled-void-return.patch +++ b/0169-Introduce-function-grub_debug_is_enabled-void-return.patch @@ -14,10 +14,10 @@ Signed-off-by: Renaud Métrich 2 files changed, 14 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index bc23945a3c2..d729b439072 100644 +index 9f54b6b7d2d..a186ad3dd41 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -162,6 +162,19 @@ int grub_err_printf (const char *fmt, ...) +@@ -163,6 +163,19 @@ int grub_err_printf (const char *fmt, ...) __attribute__ ((alias("grub_printf"))); #endif @@ -38,10 +38,10 @@ index bc23945a3c2..d729b439072 100644 grub_debug_enabled (const char * condition) { diff --git a/include/grub/misc.h b/include/grub/misc.h -index 998e47e0ccf..f05e1947c4a 100644 +index 3adc4036e3b..6c4aa85ac50 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h -@@ -385,6 +385,7 @@ grub_puts (const char *s) +@@ -340,6 +340,7 @@ grub_puts (const char *s) } int EXPORT_FUNC(grub_puts_) (const char *s); diff --git a/0273-Don-t-clear-screen-when-debugging-is-enabled.patch b/0170-Don-t-clear-screen-when-debugging-is-enabled.patch similarity index 95% rename from 0273-Don-t-clear-screen-when-debugging-is-enabled.patch rename to 0170-Don-t-clear-screen-when-debugging-is-enabled.patch index 70f45e7..d2a5988 100644 --- a/0273-Don-t-clear-screen-when-debugging-is-enabled.patch +++ b/0170-Don-t-clear-screen-when-debugging-is-enabled.patch @@ -12,7 +12,7 @@ Signed-off-by: Renaud Métrich 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index f7ee912e715..abdccc86a59 100644 +index e349303c29b..155bf366da2 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -210,7 +210,8 @@ void diff --git a/0274-grub_file_-instrumentation-new-file-debug-tag.patch b/0171-grub_file_-instrumentation-new-file-debug-tag.patch similarity index 100% rename from 0274-grub_file_-instrumentation-new-file-debug-tag.patch rename to 0171-grub_file_-instrumentation-new-file-debug-tag.patch diff --git a/0275-ieee1275-Avoiding-many-unecessary-open-close.patch b/0172-ieee1275-Avoiding-many-unecessary-open-close.patch similarity index 100% rename from 0275-ieee1275-Avoiding-many-unecessary-open-close.patch rename to 0172-ieee1275-Avoiding-many-unecessary-open-close.patch diff --git a/0276-ieee1275-powerpc-implements-fibre-channel-discovery-.patch b/0173-ieee1275-powerpc-implements-fibre-channel-discovery-.patch similarity index 100% rename from 0276-ieee1275-powerpc-implements-fibre-channel-discovery-.patch rename to 0173-ieee1275-powerpc-implements-fibre-channel-discovery-.patch diff --git a/0277-ieee1275-powerpc-enables-device-mapper-discovery.patch b/0174-ieee1275-powerpc-enables-device-mapper-discovery.patch similarity index 100% rename from 0277-ieee1275-powerpc-enables-device-mapper-discovery.patch rename to 0174-ieee1275-powerpc-enables-device-mapper-discovery.patch diff --git a/0303-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch b/0175-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch similarity index 99% rename from 0303-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch rename to 0175-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch index 2f053c8..968a9c1 100644 --- a/0303-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch +++ b/0175-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch @@ -29,7 +29,7 @@ solution": 1 file changed, 96 insertions(+), 25 deletions(-) diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c -index 69d99b61df5..c805cccbdde 100644 +index 26014382608..dac0f946fe6 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -31,6 +31,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/0280-Add-suport-for-signing-grub-with-an-appended-signatu.patch b/0176-Add-suport-for-signing-grub-with-an-appended-signatu.patch similarity index 77% rename from 0280-Add-suport-for-signing-grub-with-an-appended-signatu.patch rename to 0176-Add-suport-for-signing-grub-with-an-appended-signatu.patch index c8af937..75e8dda 100644 --- a/0280-Add-suport-for-signing-grub-with-an-appended-signatu.patch +++ b/0176-Add-suport-for-signing-grub-with-an-appended-signatu.patch @@ -43,21 +43,21 @@ that verifies these signatures. You can find one at: I will be proposing this for inclusion in a future Power Architecture Platform Reference (PAPR). --- - util/grub-install-common.c | 16 +++++++++++++--- - util/grub-mkimage.c | 11 +++++++++++ + util/grub-install-common.c | 18 ++++++++++++++++-- + util/grub-mkimage.c | 16 ++++++++++++++-- util/grub-mkimagexx.c | 39 ++++++++++++++++++++++++++++++++++++++- - util/mkimage.c | 10 +++++----- + util/mkimage.c | 13 +++++++------ include/grub/util/install.h | 8 ++++++-- include/grub/util/mkimage.h | 4 ++-- - 6 files changed, 75 insertions(+), 13 deletions(-) + 6 files changed, 83 insertions(+), 15 deletions(-) diff --git a/util/grub-install-common.c b/util/grub-install-common.c -index 0295d40f5e4..e2be0a3e305 100644 +index b4f28840f10..a53f0a5c496 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c -@@ -308,10 +308,12 @@ handle_install_list (struct install_list *il, const char *val, - static char **pubkeys; - static size_t npubkeys; +@@ -335,10 +335,12 @@ static size_t npubkeys; + static char *sbat; + static int disable_shim_lock; static grub_compression_t compression; +static size_t appsig_size; @@ -68,7 +68,7 @@ index 0295d40f5e4..e2be0a3e305 100644 switch (key) { case 'C': -@@ -400,6 +402,12 @@ grub_install_parse (int key, char *arg) +@@ -436,6 +438,12 @@ grub_install_parse (int key, char *arg) grub_util_error (_("Unrecognized compression `%s'"), arg); case GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE: return 1; @@ -81,51 +81,51 @@ index 0295d40f5e4..e2be0a3e305 100644 default: return 0; } -@@ -498,10 +506,12 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, - grub_util_info ("grub-mkimage --directory '%s' --prefix '%s'" - " --output '%s' " - " --dtb '%s' " -- "--format '%s' --compression '%s' %s %s\n", +@@ -539,7 +547,13 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, + dir, prefix, + outname, dtb ? : "", sbat ? : "", mkimage_target, + compnames[compression], note ? "--note" : "", +- disable_shim_lock ? "--disable-shim-lock" : "", s); ++ disable_shim_lock ? "--disable-shim-lock" : "", + "--format '%s' --compression '%s' " + "--appended-signature-size %zu %s %s\n", - dir, prefix, - outname, dtb ? : "", mkimage_target, -- compnames[compression], note ? "--note" : "", s); ++ dir, prefix, ++ outname, dtb ? : "", mkimage_target, + compnames[compression], appsig_size, + note ? "--note" : "", s); free (s); tgt = grub_install_get_image_target (mkimage_target); -@@ -511,7 +521,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, +@@ -549,7 +563,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, grub_install_generate_image (dir, prefix, fp, outname, modules.entries, memdisk_path, pubkeys, npubkeys, config_path, tgt, -- note, compression, dtb); -+ note, appsig_size, compression, dtb); +- note, compression, dtb, sbat, ++ note, appsig_size, compression, dtb, sbat, + disable_shim_lock); while (dc--) grub_install_pop_module (); - } diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c -index 912564e3622..c1e07c70dc7 100644 +index c0d55993702..26d1ecbf74e 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c -@@ -82,6 +82,7 @@ static struct argp_option options[] = { - {"format", 'O', N_("FORMAT"), 0, 0, 0}, - {"compression", 'C', "(xz|none|auto)", 0, N_("choose the compression to use for core image"), 0}, +@@ -84,6 +84,7 @@ static struct argp_option options[] = { + {"sbat", 's', N_("FILE"), 0, N_("SBAT metadata"), 0}, + {"disable-shim-lock", GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK, 0, 0, N_("disable shim_lock verifier"), 0}, {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, + {"appended-signature-size", 's', N_("SIZE"), 0, N_("Add a note segment reserving SIZE bytes for an appended signature"), 0}, { 0, 0, 0, 0, 0, 0 } }; -@@ -124,6 +125,7 @@ struct arguments - char *font; - char *config; +@@ -128,6 +129,7 @@ struct arguments + char *sbat; int note; + int disable_shim_lock; + size_t appsig_size; const struct grub_install_image_target_desc *image_target; grub_compression_t comp; }; -@@ -134,6 +136,7 @@ argp_parser (int key, char *arg, struct argp_state *state) +@@ -138,6 +140,7 @@ argp_parser (int key, char *arg, struct argp_state *state) /* Get the input argument from argp_parse, which we know is a pointer to our arguments structure. */ struct arguments *arguments = state->input; @@ -133,11 +133,11 @@ index 912564e3622..c1e07c70dc7 100644 switch (key) { -@@ -166,6 +169,13 @@ argp_parser (int key, char *arg, struct argp_state *state) +@@ -170,6 +173,13 @@ argp_parser (int key, char *arg, struct argp_state *state) arguments->note = 1; break; -+ case 's': ++ case 'S': + grub_errno = 0; + arguments->appsig_size = grub_strtol(arg, &end, 10); + if (grub_errno) @@ -147,16 +147,21 @@ index 912564e3622..c1e07c70dc7 100644 case 'm': if (arguments->memdisk) free (arguments->memdisk); -@@ -309,6 +319,7 @@ main (int argc, char *argv[]) +@@ -324,8 +334,10 @@ main (int argc, char *argv[]) arguments.memdisk, arguments.pubkeys, arguments.npubkeys, arguments.config, arguments.image_target, arguments.note, -+ arguments.appsig_size, - arguments.comp, arguments.dtb); +- arguments.comp, arguments.dtb, +- arguments.sbat, arguments.disable_shim_lock); ++ ++ arguments.comp, arguments.appsig_size, ++ arguments.dtb, arguments.sbat, ++ arguments.disable_shim_lock); if (grub_util_file_sync (fp) < 0) + grub_util_error (_("cannot sync `%s': %s"), arguments.output ? : "stdout", diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c -index 52bc9c848d9..bd2e2e9a52a 100644 +index 00f49ccaaaf..ed422bd1781 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -84,6 +84,15 @@ struct grub_ieee1275_note @@ -227,19 +232,22 @@ index 52bc9c848d9..bd2e2e9a52a 100644 char *str_start = (elf_img + sizeof (*ehdr) + phnum * sizeof (*phdr) + shnum * sizeof (*shdr)); diff --git a/util/mkimage.c b/util/mkimage.c -index 37d6249f16b..bd06968decc 100644 +index a26cf76f72f..bab12276010 100644 --- a/util/mkimage.c +++ b/util/mkimage.c -@@ -822,7 +822,7 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -869,8 +869,9 @@ grub_install_generate_image (const char *dir, const char *prefix, char *memdisk_path, char **pubkey_paths, size_t npubkeys, char *config_path, const struct grub_install_image_target_desc *image_target, -- int note, grub_compression_t comp, const char *dtb_path) -+ int note, size_t appsig_size, grub_compression_t comp, const char *dtb_path) +- int note, grub_compression_t comp, const char *dtb_path, +- const char *sbat_path, int disable_shim_lock) ++ int note, size_t appsig_size, grub_compression_t comp, ++ const char *dtb_path, const char *sbat_path, ++ int disable_shim_lock) { char *kernel_img, *core_img; size_t total_module_size, core_size; -@@ -1742,11 +1742,11 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -1773,11 +1774,11 @@ grub_install_generate_image (const char *dir, const char *prefix, else target_addr = image_target->link_addr; if (image_target->voidp_sizeof == 4) @@ -256,43 +264,43 @@ index 37d6249f16b..bd06968decc 100644 break; } diff --git a/include/grub/util/install.h b/include/grub/util/install.h -index 2631b107451..eb1b83b6d94 100644 +index b93c73caac6..b3307fef9b4 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h -@@ -63,6 +63,9 @@ - /* TRANSLATORS: "embed" is a verb (command description). "*/ \ - { "pubkey", 'k', N_("FILE"), 0, \ - N_("embed FILE as public key for signature checking"), 0}, \ +@@ -67,6 +67,9 @@ + N_("SBAT metadata"), 0 }, \ + { "disable-shim-lock", GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK, 0, 0, \ + N_("disable shim_lock verifier"), 0 }, \ + { "appended-signature-size", GRUB_INSTALL_OPTIONS_APPENDED_SIGNATURE_SIZE,\ + "SIZE", 0, N_("Add a note segment reserving SIZE bytes for an appended signature"), \ + 1}, \ { "verbose", 'v', 0, 0, \ N_("print verbose messages."), 1 } -@@ -122,7 +125,8 @@ enum grub_install_options { - GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, - GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, +@@ -128,7 +131,8 @@ enum grub_install_options { GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, -- GRUB_INSTALL_OPTIONS_DTB -+ GRUB_INSTALL_OPTIONS_DTB, + GRUB_INSTALL_OPTIONS_DTB, + GRUB_INSTALL_OPTIONS_SBAT, +- GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK ++ GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK, + GRUB_INSTALL_OPTIONS_APPENDED_SIGNATURE_SIZE }; extern char *grub_install_source_directory; -@@ -182,7 +186,7 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -188,7 +192,7 @@ grub_install_generate_image (const char *dir, const char *prefix, size_t npubkeys, char *config_path, const struct grub_install_image_target_desc *image_target, - int note, + int note, size_t appsig_size, - grub_compression_t comp, const char *dtb_file); + grub_compression_t comp, const char *dtb_file, + const char *sbat_path, const int disable_shim_lock); - const struct grub_install_image_target_desc * diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h -index ba9f568f692..2000d6fbdf1 100644 +index 3819a67441c..6f1da89b9b6 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h -@@ -50,12 +50,12 @@ grub_mkimage_load_image64 (const char *kernel_path, +@@ -51,12 +51,12 @@ grub_mkimage_load_image64 (const char *kernel_path, const struct grub_install_image_target_desc *image_target); void grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target, diff --git a/0177-autogen.sh-use-find-wholename-for-long-path-matches.patch b/0177-autogen.sh-use-find-wholename-for-long-path-matches.patch deleted file mode 100644 index 1ac3f16..0000000 --- a/0177-autogen.sh-use-find-wholename-for-long-path-matches.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 29 Jul 2019 14:01:50 -0400 -Subject: [PATCH] autogen.sh: use find -wholename for long path matches - -Signed-off-by: Peter Jones ---- - autogen.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/autogen.sh b/autogen.sh -index ef43270fca0..a1783d62c26 100755 ---- a/autogen.sh -+++ b/autogen.sh -@@ -13,7 +13,7 @@ fi - export LC_COLLATE=C - unset LC_ALL - --find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -iname './grub-core/lib/gnulib/*' |sort > po/POTFILES.in -+find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -wholename './grub-core/lib/gnulib/*' |sort > po/POTFILES.in - find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in - - echo "Importing unicode..." diff --git a/0281-docs-grub-Document-signing-grub-under-UEFI.patch b/0177-docs-grub-Document-signing-grub-under-UEFI.patch similarity index 60% rename from 0281-docs-grub-Document-signing-grub-under-UEFI.patch rename to 0177-docs-grub-Document-signing-grub-under-UEFI.patch index 387b51d..2f53d52 100644 --- a/0281-docs-grub-Document-signing-grub-under-UEFI.patch +++ b/0177-docs-grub-Document-signing-grub-under-UEFI.patch @@ -7,25 +7,24 @@ Before adding information about how grub is signed with an appended signature scheme, it's worth adding some information about how it can currently be signed for UEFI. -(adjusted from upstream - s/grub/grub2/ in the docs) Signed-off-by: Daniel Axtens --- - docs/grub.texi | 19 ++++++++++++++++++- - 1 file changed, 18 insertions(+), 1 deletion(-) + docs/grub.texi | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi -index 085b9974cc5..abb1d0fae54 100644 +index 75b22231f35..ca36ad0b6b7 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -5645,6 +5645,7 @@ environment variables and commands are listed in the same order. - @menu - * Authentication and authorisation:: Users and access control - * Using digital signatures:: Booting digitally signed code -+* Signing GRUB itself:: Ensuring the integrity of the GRUB core image - * UEFI secure boot and shim:: Booting digitally signed PE files +@@ -5814,6 +5814,7 @@ environment variables and commands are listed in the same order. + * Secure Boot Advanced Targeting:: Embedded information for generation number based revocation * Measured Boot:: Measuring boot components + * Lockdown:: Lockdown when booting on a secure setup ++* Signing GRUB itself:: Ensuring the integrity of the GRUB core image @end menu -@@ -5724,7 +5725,7 @@ commands. + + @node Authentication and authorisation +@@ -5892,7 +5893,7 @@ commands. GRUB's @file{core.img} can optionally provide enforcement that all files subsequently read from disk are covered by a valid digital signature. @@ -34,9 +33,9 @@ index 085b9974cc5..abb1d0fae54 100644 platform's firmware (e.g., Coreboot) validates @file{core.img}. If environment variable @code{check_signatures} -@@ -5809,6 +5810,22 @@ or BIOS) configuration to cause the machine to boot from a different - (attacker-controlled) device. GRUB is at best only one link in a - secure boot chain. +@@ -6064,6 +6065,25 @@ be restricted and some operations/commands cannot be executed. + The @samp{lockdown} variable is set to @samp{y} when the GRUB is locked down. + Otherwise it does not exit. +@node Signing GRUB itself +@section Signing GRUB itself @@ -51,9 +50,12 @@ index 085b9974cc5..abb1d0fae54 100644 +@section Signing GRUB for UEFI secure boot + +On UEFI platforms, @file{core.img} is a PE binary. Therefore, it can be signed -+with a tool such as @command{pesign} or @command{sbsign}. It will also be -+necessary to enrol the public key used into a relevant firmware key database. ++with a tool such as @command{pesign} or @command{sbsign}. Refer to the ++suggestions in @pxref{UEFI secure boot and shim} to ensure that the final ++image works under UEFI secure boot and can maintain the secure-boot chain. It ++will also be necessary to enrol the public key used into a relevant firmware ++key database. + - @node UEFI secure boot and shim - @section UEFI secure boot and shim support + @node Platform limitations + @chapter Platform limitations diff --git a/0178-bootstrap.conf-don-t-clobber-AM_CFLAGS-here.patch b/0178-bootstrap.conf-don-t-clobber-AM_CFLAGS-here.patch deleted file mode 100644 index 3a0e5bc..0000000 --- a/0178-bootstrap.conf-don-t-clobber-AM_CFLAGS-here.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 29 Jul 2019 14:02:11 -0400 -Subject: [PATCH] bootstrap.conf: don't clobber AM_CFLAGS here - ---- - bootstrap.conf | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/bootstrap.conf b/bootstrap.conf -index 24ea40b2fc5..274c55a5568 100644 ---- a/bootstrap.conf -+++ b/bootstrap.conf -@@ -84,9 +84,6 @@ cp -a INSTALL INSTALL.grub - - bootstrap_post_import_hook () { - set -e -- for flagvar in CPPFLAGS CFLAGS; do -- sed -i -e "s/^AM_$flagvar =/AM_$flagvar = \$(HOST_$flagvar)/" grub-core/lib/gnulib/Makefile.am -- done - FROM_BOOTSTRAP=1 ./autogen.sh - set +e # bootstrap expects this - } diff --git a/0282-docs-grub-Document-signing-grub-with-an-appended-sig.patch b/0178-docs-grub-Document-signing-grub-with-an-appended-sig.patch similarity index 76% rename from 0282-docs-grub-Document-signing-grub-with-an-appended-sig.patch rename to 0178-docs-grub-Document-signing-grub-with-an-appended-sig.patch index cff60cf..29db2bb 100644 --- a/0282-docs-grub-Document-signing-grub-with-an-appended-sig.patch +++ b/0178-docs-grub-Document-signing-grub-with-an-appended-sig.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 8 Feb 2021 19:17:55 +0100 +From: Daniel Axtens +Date: Sat, 15 Aug 2020 02:19:36 +1000 Subject: [PATCH] docs/grub: Document signing grub with an appended signature Signing grub for firmware that verifies an appended signature is a @@ -9,24 +9,24 @@ so document it here. Signed-off-by: Daniel Axtens --- - docs/grub.texi | 41 +++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 41 insertions(+) + docs/grub.texi | 42 ++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 42 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi -index abb1d0fae54..e8bfe7ee7e8 100644 +index ca36ad0b6b7..691ffaa1861 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -5826,6 +5826,47 @@ On UEFI platforms, @file{core.img} is a PE binary. Therefore, it can be signed - with a tool such as @command{pesign} or @command{sbsign}. It will also be - necessary to enrol the public key used into a relevant firmware key database. +@@ -6084,6 +6084,48 @@ image works under UEFI secure boot and can maintain the secure-boot chain. It + will also be necessary to enrol the public key used into a relevant firmware + key database. +@section Signing GRUB with an appended signature + -+The @file{core.img} itself can be signed with a Linux kernel module-style ++The @file{core.elf} itself can be signed with a Linux kernel module-style +appended signature. + +To support IEEE1275 platforms where the boot image is often loaded directly -+from a disk partition rather than from a file system, the @file{core.img} ++from a disk partition rather than from a file system, the @file{core.elf} +can specify the size and location of the appended signature with an ELF +note added by @command{grub-install}. + @@ -61,6 +61,7 @@ index abb1d0fae54..e8bfe7ee7e8 100644 +As with UEFI secure boot, it is necessary to build in the required modules, +or sign them separately. + - @node UEFI secure boot and shim - @section UEFI secure boot and shim support ++ + @node Platform limitations + @chapter Platform limitations diff --git a/0285-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch b/0179-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch similarity index 92% rename from 0285-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch rename to 0179-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch index 7429d64..6e46db0 100644 --- a/0285-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch +++ b/0179-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch @@ -16,10 +16,10 @@ Signed-off-by: Daniel Axtens 1 file changed, 11 insertions(+) diff --git a/include/grub/dl.h b/include/grub/dl.h -index 4fe2b524f73..177bcd67a25 100644 +index 2f76e6b0437..20d870f2a47 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h -@@ -243,11 +243,22 @@ grub_dl_get (const char *name) +@@ -245,11 +245,22 @@ grub_dl_get (const char *name) return 0; } diff --git a/0180-RISC-V-Fix-computation-of-pc-relative-relocation-off.patch b/0180-RISC-V-Fix-computation-of-pc-relative-relocation-off.patch deleted file mode 100644 index 582cadb..0000000 --- a/0180-RISC-V-Fix-computation-of-pc-relative-relocation-off.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Andreas Schwab -Date: Wed, 26 Jun 2019 16:50:03 +0200 -Subject: [PATCH] RISC-V: Fix computation of pc-relative relocation offset - -The offset calculation was missing the relocation addend. - -Signed-off-by: Andreas Schwab -Tested-by: Chester Lin -Reviewed-by: Daniel Kiper ---- - util/grub-mkimagexx.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c -index bc087c2b57f..d16ec63a16f 100644 ---- a/util/grub-mkimagexx.c -+++ b/util/grub-mkimagexx.c -@@ -1232,8 +1232,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, - grub_uint32_t *t32 = (grub_uint32_t *) target; - grub_uint16_t *t16 = (grub_uint16_t *) target; - grub_uint8_t *t8 = (grub_uint8_t *) target; -- grub_int64_t off = (long)sym_addr - target_section_addr - offset -- - image_target->vaddr_offset; -+ grub_int64_t off; - - /* - * Instructions and instruction encoding are documented in the RISC-V -@@ -1243,6 +1242,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, - */ - - sym_addr += addend; -+ off = sym_addr - target_section_addr - offset - image_target->vaddr_offset; - - switch (ELF_R_TYPE (info)) - { diff --git a/0287-pgp-factor-out-rsa_pad.patch b/0180-pgp-factor-out-rsa_pad.patch similarity index 98% rename from 0287-pgp-factor-out-rsa_pad.patch rename to 0180-pgp-factor-out-rsa_pad.patch index 3d4e191..a8154e7 100644 --- a/0287-pgp-factor-out-rsa_pad.patch +++ b/0180-pgp-factor-out-rsa_pad.patch @@ -27,10 +27,10 @@ Signed-off-by: Daniel Axtens create mode 100644 include/grub/pkcs1_v15.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index b283c502b9c..58bf113e7c1 100644 +index 81fc274148e..97347ae76f9 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2488,6 +2488,14 @@ module = { +@@ -2510,6 +2510,14 @@ module = { cppflags = '$(CPPFLAGS_GCRY)'; }; @@ -46,7 +46,7 @@ index b283c502b9c..58bf113e7c1 100644 name = all_video; common = lib/fake_module.c; diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c -index bbf6871fe71..2032afa4ec6 100644 +index 5daa1e9d00c..2408db4994f 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -24,6 +24,7 @@ diff --git a/0181-blscfg-Add-support-for-the-devicetree-field.patch b/0181-blscfg-Add-support-for-the-devicetree-field.patch deleted file mode 100644 index 8c971af..0000000 --- a/0181-blscfg-Add-support-for-the-devicetree-field.patch +++ /dev/null @@ -1,132 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Sun, 15 Sep 2019 09:37:45 +0200 -Subject: [PATCH] blscfg: Add support for the devicetree field - -The BootLoaderSpec mentions that a devicetree field can be used to pass a -Device Tree (DT) to the kernel, for the platforms that use it to describe -information about the hardware. - -Allow the blscfg module to parse this field and call the grub2 devicetree -command in that case. If there is a devicetree grub2 environment variable -defined, this will be used if the field is not defined in the BLS snippet. - -Resolves: rhbz#1751307 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 60 ++++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 57 insertions(+), 3 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 54458b14518..1ec89870483 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -698,6 +698,8 @@ static void create_entry (struct bls_entry *entry) - const char *early_initrd = NULL; - char **early_initrds = NULL; - char *initrd_prefix = NULL; -+ char *devicetree = NULL; -+ char *dt = NULL; - char *id = entry->filename; - char *dotconf = id; - char *hotkey = NULL; -@@ -709,6 +711,7 @@ static void create_entry (struct bls_entry *entry) - - char *src = NULL; - int i, index; -+ bool add_dt_prefix = false; - - grub_dprintf("blscfg", "%s got here\n", __func__); - clinux = bls_get_val (entry, "linux", NULL); -@@ -736,6 +739,14 @@ static void create_entry (struct bls_entry *entry) - - initrds = bls_make_list (entry, "initrd", NULL); - -+ devicetree = expand_val (bls_get_val (entry, "devicetree", NULL)); -+ -+ if (!devicetree) -+ { -+ devicetree = expand_val (grub_env_get("devicetree")); -+ add_dt_prefix = true; -+ } -+ - hotkey = bls_get_val (entry, "grub_hotkey", NULL); - users = expand_val (bls_get_val (entry, "grub_users", NULL)); - classes = bls_make_list (entry, "grub_class", NULL); -@@ -801,7 +812,6 @@ static void create_entry (struct bls_entry *entry) - goto finish; - } - -- - tmp = grub_stpcpy(initrd, "initrd"); - for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) - { -@@ -821,21 +831,65 @@ static void create_entry (struct bls_entry *entry) - tmp = grub_stpcpy (tmp, "\n"); - } - -+ if (devicetree) -+ { -+ char *prefix = NULL; -+ int dt_size; -+ -+ if (add_dt_prefix) -+ { -+ prefix = grub_strrchr (clinux, '/'); -+ prefix = grub_strndup(clinux, prefix - clinux + 1); -+ if (!prefix) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto finish; -+ } -+ } -+ -+ dt_size = sizeof("devicetree " GRUB_BOOT_DEVICE) + grub_strlen(devicetree) + 1; -+ -+ if (add_dt_prefix) -+ { -+ dt_size += grub_strlen(prefix); -+ } -+ -+ dt = grub_malloc (dt_size); -+ if (!dt) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto finish; -+ } -+ char *tmp = dt; -+ tmp = grub_stpcpy (dt, "devicetree"); -+ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); -+ if (add_dt_prefix) -+ tmp = grub_stpcpy (tmp, prefix); -+ tmp = grub_stpcpy (tmp, devicetree); -+ tmp = grub_stpcpy (tmp, "\n"); -+ -+ grub_free(prefix); -+ } -+ -+ grub_dprintf ("blscfg2", "devicetree %s for id:\"%s\"\n", dt, id); -+ - src = grub_xasprintf ("load_video\n" - "set gfxpayload=keep\n" - "insmod gzio\n" - "linux %s%s%s%s\n" -- "%s", -+ "%s%s", - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", -- initrd ? initrd : ""); -+ initrd ? initrd : "", dt ? dt : ""); - - grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index, entry); - grub_dprintf ("blscfg", "Added entry %d id:\"%s\"\n", index, id); - - finish: -+ grub_free (dt); - grub_free (initrd); - grub_free (initrd_prefix); - grub_free (early_initrds); -+ grub_free (devicetree); - grub_free (initrds); - grub_free (options); - grub_free (classes); diff --git a/0288-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch b/0181-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch similarity index 96% rename from 0288-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch rename to 0181-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch index adfb680..763cdc6 100644 --- a/0288-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch +++ b/0181-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch @@ -40,7 +40,7 @@ Signed-off-by: Daniel Axtens 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c -index 2032afa4ec6..4e0667c1cd0 100644 +index 2408db4994f..355a43844ac 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -147,10 +147,6 @@ const char *hashes[] = { @@ -55,7 +55,7 @@ index 2032afa4ec6..4e0667c1cd0 100644 dsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval, const gcry_md_spec_t *hash, struct grub_public_subkey *sk); diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c -index e6c78d16d39..ff62fa30e1a 100644 +index ca334d5a40e..c578128a59d 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -121,6 +121,10 @@ grub_md_unregister (gcry_md_spec_t *cipher) diff --git a/0182-Set-a-devicetree-var-in-a-BLS-config-if-GRUB_DEFAULT.patch b/0182-Set-a-devicetree-var-in-a-BLS-config-if-GRUB_DEFAULT.patch deleted file mode 100644 index 2da87d6..0000000 --- a/0182-Set-a-devicetree-var-in-a-BLS-config-if-GRUB_DEFAULT.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Sun, 15 Sep 2019 10:05:29 +0200 -Subject: [PATCH] Set a devicetree var in a BLS config if GRUB_DEFAULT_DTB is - present - -The BootLoaderSpec mentions that a devicetree field can be used to pass a -Device Tree (DT) to the kernel, for the platforms that use it to describe -information about the hardware. - -The blscfg module supports parsing the field from the BLS snippets but it -allows to set a DT for all the entries if a devicetree env var is defined. - -Make the grub2-mkconfig tool to set this variable if GRUB_DEFAULT_DTB was -defined in the /etc/default/grub file. - -Resolves: rhbz#1751307 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 301594a0c9e..1520b7e47c1 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -138,6 +138,10 @@ EOF - if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then - ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" - fi -+ -+ if [ -n "${GRUB_DEFAULT_DTB}" ]; then -+ ${grub_editenv} - set devicetree="${GRUB_DEFAULT_DTB}" -+ fi - fi - - exit 0 diff --git a/0289-posix_wrap-tweaks-in-preparation-for-libtasn1.patch b/0182-posix_wrap-tweaks-in-preparation-for-libtasn1.patch similarity index 100% rename from 0289-posix_wrap-tweaks-in-preparation-for-libtasn1.patch rename to 0182-posix_wrap-tweaks-in-preparation-for-libtasn1.patch diff --git a/0183-Don-t-add-a-class-option-to-menu-entries-generated-f.patch b/0183-Don-t-add-a-class-option-to-menu-entries-generated-f.patch deleted file mode 100644 index d136618..0000000 --- a/0183-Don-t-add-a-class-option-to-menu-entries-generated-f.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 4 Oct 2019 16:43:05 +0200 -Subject: [PATCH] Don't add a class option to menu entries generated for - ppc64le - -For ppc64le a grub config file with menuentry commands is still generated -even when BLS support is enabled. That's because BLS support was added to -Petitboot 1.8.0 and any previous version won't be able to parse BLS files. - -To make the BLS snippets the source of truth, these are used to generate -the menuentry commands in the grub config file. - -And to keep it consistent across all ppc64le machines regardless of the -firmware used, the grub config file is also generated for machines with -OF that use grub2 and would have BLS support. - -The BLS snippets created by the kernel package have fields that are used -to specify the generated menuentry command users and class options. These -fields are not present in BLS snippets created by OSTree though, so the -script generating the menuentry commands will add options with an empty -argument which will lead to grub failing to parse them. - -We could check if the field is defined before attempting to add those, but -since the grub2 blscfg module also supports setting these to variables, it -could lead to an empty argument even if was defined in the BLS snippet if -the variable doesn't exist. - -So to make more robust, just don't add a class to the menuentry commands -generated by the script. It's better to not have a class for the menuentry -than grub2 failing to parse the command and not populating the boot menu. - -Resolves: rhbz#1758225 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux_bls.in | 10 +--------- - 1 file changed, 1 insertion(+), 9 deletions(-) - -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 1b7536435f1..68fbedf2129 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -127,9 +127,7 @@ read_config() - initrd="" - options="" - linux="" -- grub_users="" - grub_arg="" -- grub_class="" - - while read -r line - do -@@ -148,15 +146,9 @@ read_config() - "options") - options=${value} - ;; -- "grub_users") -- grub_users=${value} -- ;; - "grub_arg") - grub_arg=${value} - ;; -- "grub_class") -- grub_class=${value} -- ;; - esac - done < ${config_file} - } -@@ -180,7 +172,7 @@ populate_menu() - for bls in "${files[@]}" ; do - read_config "${blsdir}/${bls}.conf" - -- menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id=${bls} {\n" -+ menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" - menu="${menu}\t linux ${linux} ${options}\n" - if [ -n "${initrd}" ] ; then - menu="${menu}\t initrd ${boot_prefix}${initrd}\n" diff --git a/0290-libtasn1-import-libtasn1-4.16.0.patch b/0183-libtasn1-import-libtasn1-4.16.0.patch similarity index 100% rename from 0290-libtasn1-import-libtasn1-4.16.0.patch rename to 0183-libtasn1-import-libtasn1-4.16.0.patch diff --git a/0184-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch b/0184-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch deleted file mode 100644 index f4aa008..0000000 --- a/0184-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 15 Oct 2019 09:08:25 +0200 -Subject: [PATCH] 10_linux.in: Also use GRUB_CMDLINE_LINUX_DEFAULT to set - kernelopts - -The GRUB documentation mentions that there are two variables to set the -linux kernel cmdline: GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT. - -The former is added to all the menuentry commands and the latter is not -added to the recovery mode menu entries. But the blscfg module doesn't -populate recovery entries from the BLS snippets, so the values set in the -GRUB_CMDLINE_LINUX_DEFAULT variable should also be included in kernelopts. - -This is needed because the GRUB_CMDLINE_LINUX_DEFAULT option is mentioned -in the GRUB documentation so users assume that the kernel cmdline options -can be changed by setting this option and running the grub2-mkconfig tool. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 1520b7e47c1..0471464e68e 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -118,7 +118,7 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - populate_header_warn - - cat << EOF --set default_kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX}" -+set default_kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - - insmod blscfg - blscfg -@@ -134,7 +134,7 @@ EOF - fi - fi - -- ${grub_editenv} - set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX}" -+ ${grub_editenv} - set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then - ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" - fi diff --git a/0291-libtasn1-disable-code-not-needed-in-grub.patch b/0184-libtasn1-disable-code-not-needed-in-grub.patch similarity index 100% rename from 0291-libtasn1-disable-code-not-needed-in-grub.patch rename to 0184-libtasn1-disable-code-not-needed-in-grub.patch diff --git a/0185-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch b/0185-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch deleted file mode 100644 index 669c770..0000000 --- a/0185-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 14 Oct 2019 17:37:26 +0200 -Subject: [PATCH] blscfg: Don't hardcode an env var as fallback for the BLS - options field - -If the BLS fragments don't have an options field or if this was set to an -environment variable that was not defined in the grubenv file, the blscfg -module searches for an default_kernelopts variable that is defined in the -grub.cfg file. - -But the blscfg module shouldn't hardcode fallbacks variables and instead -this logic should be handled in the GRUB config file itself. - -Also, add a comment explaining where the kernelopts variable is supposed -to be defined and what is the process for the user to change its value. - -Resolves: rhbz#1710483 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 4 ---- - util/grub.d/10_linux.in | 12 +++++++++++- - 2 files changed, 11 insertions(+), 5 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 1ec89870483..471975fd2e5 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -733,10 +733,6 @@ static void create_entry (struct bls_entry *entry) - - title = bls_get_val (entry, "title", NULL); - options = expand_val (bls_get_val (entry, "options", NULL)); -- -- if (!options) -- options = expand_val (grub_env_get("default_kernelopts")); -- - initrds = bls_make_list (entry, "initrd", NULL); - - devicetree = expand_val (bls_get_val (entry, "devicetree", NULL)); -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 0471464e68e..21a6915dca3 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -118,7 +118,17 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - populate_header_warn - - cat << EOF --set default_kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -+# The kernelopts variable should be defined in the grubenv file. But to ensure that menu -+# entries populated from BootLoaderSpec files that use this variable work correctly even -+# without a grubenv file, define a fallback kernelopts variable if this has not been set. -+# -+# The kernelopts variable in the grubenv file can be modified using the grubby tool or by -+# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX -+# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both -+# the kernelopts variable in the grubenv file and the fallback kernelopts variable. -+if [ -z "\${kernelopts}" ]; then -+ set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -+fi - - insmod blscfg - blscfg diff --git a/0292-libtasn1-changes-for-grub-compatibility.patch b/0185-libtasn1-changes-for-grub-compatibility.patch similarity index 100% rename from 0292-libtasn1-changes-for-grub-compatibility.patch rename to 0185-libtasn1-changes-for-grub-compatibility.patch diff --git a/0293-libtasn1-compile-into-asn1-module.patch b/0186-libtasn1-compile-into-asn1-module.patch similarity index 97% rename from 0293-libtasn1-compile-into-asn1-module.patch rename to 0186-libtasn1-compile-into-asn1-module.patch index 2ee3d9a..67be4e8 100644 --- a/0293-libtasn1-compile-into-asn1-module.patch +++ b/0186-libtasn1-compile-into-asn1-module.patch @@ -14,10 +14,10 @@ Signed-off-by: Daniel Axtens create mode 100644 grub-core/lib/libtasn1_wrap/wrap.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 58bf113e7c1..a9f589a7b99 100644 +index 97347ae76f9..21d2c541850 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2554,3 +2554,18 @@ module = { +@@ -2576,3 +2576,18 @@ module = { common = commands/i386/wrmsr.c; enable = x86; }; diff --git a/0294-test_asn1-test-module-for-libtasn1.patch b/0187-test_asn1-test-module-for-libtasn1.patch similarity index 99% rename from 0294-test_asn1-test-module-for-libtasn1.patch rename to 0187-test_asn1-test-module-for-libtasn1.patch index 6036148..3a02b24 100644 --- a/0294-test_asn1-test-module-for-libtasn1.patch +++ b/0187-test_asn1-test-module-for-libtasn1.patch @@ -51,10 +51,10 @@ Signed-off-by: Daniel Axtens create mode 100644 tests/test_asn1.in diff --git a/Makefile.util.def b/Makefile.util.def -index dc8d1790ea5..d7908cbd1a0 100644 +index e1242f54022..8cfbe69a76e 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1304,6 +1304,12 @@ script = { +@@ -1305,6 +1305,12 @@ script = { common = tests/syslinux_test.in; }; @@ -68,10 +68,10 @@ index dc8d1790ea5..d7908cbd1a0 100644 testcase; name = example_unit_test; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index a9f589a7b99..78071360529 100644 +index 21d2c541850..b4aaccf7b57 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2569,3 +2569,16 @@ module = { +@@ -2591,3 +2591,16 @@ module = { // -Wno-type-limits comes from libtasn1's configure.ac cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/libtasn1/lib -Wno-type-limits'; }; @@ -1426,15 +1426,17 @@ index 00000000000..555e56dd202 + +#endif diff --git a/.gitignore b/.gitignore -index b45a633f3d1..0687c3cb5a2 100644 +index 594d0134d33..856e69bc5c1 100644 --- a/.gitignore +++ b/.gitignore -@@ -148,4 +148,5 @@ grub-*.tar.* - /libgrub_a_init.c - /libgrub_a_init.lst - /stamp-h.in +@@ -264,6 +264,7 @@ widthspec.bin + /stamp-h1 + /syslinux_test + /tar_test +/test_asn1 - /widthspec.h + /test_sha512sum + /test_unset + /tests/syslinux/ubuntu10.04_grub.cfg diff --git a/tests/test_asn1.in b/tests/test_asn1.in new file mode 100644 index 00000000000..8173c5c270e diff --git a/0188-blscfg-add-a-space-char-when-appending-fields-for-va.patch b/0188-blscfg-add-a-space-char-when-appending-fields-for-va.patch deleted file mode 100644 index 9f69238..0000000 --- a/0188-blscfg-add-a-space-char-when-appending-fields-for-va.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 26 Nov 2019 09:51:41 +0100 -Subject: [PATCH] blscfg: add a space char when appending fields for variable - expansion - -The GRUB variables are expanded and replaced by their values before adding -menu entries, but they didn't include space characters after the values so -the result was not correct. - -For the common case this wasn't a problem but it is if there are variables -that are part of the values of other variables. - -Resolves: rhbz#1669252 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 31 ++++++++++++++++++------------- - 1 file changed, 18 insertions(+), 13 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 471975fd2e5..d78cff79f97 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -593,26 +593,29 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) - - static char *field_append(bool is_var, char *buffer, char *start, char *end) - { -- char *temp = grub_strndup(start, end - start + 1); -- const char *field = temp; -+ char *tmp = grub_strndup(start, end - start + 1); -+ const char *field = tmp; -+ int term = is_var ? 2 : 1; - - if (is_var) { -- field = grub_env_get (temp); -+ field = grub_env_get (tmp); - if (!field) - return buffer; - } - -- if (!buffer) { -- buffer = grub_strdup(field); -- if (!buffer) -- return NULL; -- } else { -- buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field)); -- if (!buffer) -- return NULL; -+ if (!buffer) -+ buffer = grub_zalloc (grub_strlen(field) + term); -+ else -+ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field) + term); - -- grub_stpcpy (buffer + grub_strlen(buffer), field); -- } -+ if (!buffer) -+ return NULL; -+ -+ tmp = buffer + grub_strlen(buffer); -+ tmp = grub_stpcpy (tmp, field); -+ -+ if (is_var) -+ tmp = grub_stpcpy (tmp, " "); - - return buffer; - } -@@ -642,6 +645,8 @@ static char *expand_val(char *value) - buffer = field_append(is_var, buffer, start, end); - is_var = false; - start = value; -+ if (*start == ' ') -+ start++; - } - } - diff --git a/0295-grub-install-support-embedding-x509-certificates.patch b/0188-grub-install-support-embedding-x509-certificates.patch similarity index 77% rename from 0295-grub-install-support-embedding-x509-certificates.patch rename to 0188-grub-install-support-embedding-x509-certificates.patch index 2bc196a..4d13e3c 100644 --- a/0295-grub-install-support-embedding-x509-certificates.patch +++ b/0188-grub-install-support-embedding-x509-certificates.patch @@ -12,15 +12,15 @@ Signed-off-by: Alastair D'Silva Signed-off-by: Daniel Axtens --- grub-core/commands/pgp.c | 2 +- - util/grub-install-common.c | 23 ++++++++++++++++++++++- + util/grub-install-common.c | 22 +++++++++++++++++++++- util/grub-mkimage.c | 15 +++++++++++++-- - util/mkimage.c | 41 ++++++++++++++++++++++++++++++++++++++--- - include/grub/kernel.h | 3 ++- + util/mkimage.c | 38 ++++++++++++++++++++++++++++++++++++-- + include/grub/kernel.h | 4 +++- include/grub/util/install.h | 7 +++++-- - 6 files changed, 81 insertions(+), 10 deletions(-) + 6 files changed, 79 insertions(+), 9 deletions(-) diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c -index 4e0667c1cd0..3cd31f50b5b 100644 +index 355a43844ac..b81ac0ae46c 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -944,7 +944,7 @@ GRUB_MOD_INIT(pgp) @@ -33,32 +33,31 @@ index 4e0667c1cd0..3cd31f50b5b 100644 pseudo_file.fs = &pseudo_fs; diff --git a/util/grub-install-common.c b/util/grub-install-common.c -index e2be0a3e305..65cde2fa2f0 100644 +index a53f0a5c496..917904ee73d 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c -@@ -307,6 +307,8 @@ handle_install_list (struct install_list *il, const char *val, - - static char **pubkeys; +@@ -334,6 +334,8 @@ static char **pubkeys; static size_t npubkeys; + static char *sbat; + static int disable_shim_lock; +static char **x509keys; +static size_t nx509keys; static grub_compression_t compression; static size_t appsig_size; -@@ -339,6 +341,12 @@ grub_install_parse (int key, char *arg) - * (npubkeys + 1)); - pubkeys[npubkeys++] = xstrdup (arg); +@@ -374,6 +376,11 @@ grub_install_parse (int key, char *arg) return 1; + case GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK: + disable_shim_lock = 1; + case 'x': + x509keys = xrealloc (x509keys, + sizeof (x509keys[0]) + * (nx509keys + 1)); + x509keys[nx509keys++] = xstrdup (arg); -+ return 1; + return 1; case GRUB_INSTALL_OPTIONS_VERBOSITY: - verbosity++; -@@ -465,6 +473,9 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, +@@ -501,6 +508,9 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, for (pk = pubkeys; pk < pubkeys + npubkeys; pk++) slen += 20 + grub_strlen (*pk); @@ -68,7 +67,7 @@ index e2be0a3e305..65cde2fa2f0 100644 for (md = modules.entries; *md; md++) { slen += 10 + grub_strlen (*md); -@@ -493,6 +504,14 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, +@@ -529,6 +539,14 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, *p++ = ' '; } @@ -83,7 +82,7 @@ index e2be0a3e305..65cde2fa2f0 100644 for (md = modules.entries; *md; md++) { *p++ = '\''; -@@ -520,7 +539,9 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, +@@ -562,7 +580,9 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, grub_install_generate_image (dir, prefix, fp, outname, modules.entries, memdisk_path, @@ -91,11 +90,11 @@ index e2be0a3e305..65cde2fa2f0 100644 + pubkeys, npubkeys, + x509keys, nx509keys, + config_path, tgt, - note, appsig_size, compression, dtb); + note, appsig_size, compression, dtb, sbat, + disable_shim_lock); while (dc--) - grub_install_pop_module (); diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c -index c1e07c70dc7..6034c51ece4 100644 +index 26d1ecbf74e..c5cdda498eb 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -75,7 +75,8 @@ static struct argp_option options[] = { @@ -108,7 +107,7 @@ index c1e07c70dc7..6034c51ece4 100644 /* TRANSLATORS: NOTE is a name of segment. */ {"note", 'n', 0, 0, N_("add NOTE segment for CHRP IEEE1275"), 0}, {"output", 'o', N_("FILE"), 0, N_("output a generated image to FILE [default=stdout]"), 0}, -@@ -122,6 +123,8 @@ struct arguments +@@ -124,6 +125,8 @@ struct arguments char *dtb; char **pubkeys; size_t npubkeys; @@ -116,8 +115,8 @@ index c1e07c70dc7..6034c51ece4 100644 + size_t nx509keys; char *font; char *config; - int note; -@@ -202,6 +205,13 @@ argp_parser (int key, char *arg, struct argp_state *state) + char *sbat; +@@ -206,6 +209,13 @@ argp_parser (int key, char *arg, struct argp_state *state) arguments->pubkeys[arguments->npubkeys++] = xstrdup (arg); break; @@ -131,7 +130,7 @@ index c1e07c70dc7..6034c51ece4 100644 case 'c': if (arguments->config) free (arguments->config); -@@ -317,7 +327,8 @@ main (int argc, char *argv[]) +@@ -332,7 +342,8 @@ main (int argc, char *argv[]) grub_install_generate_image (arguments.dir, arguments.prefix, fp, arguments.output, arguments.modules, arguments.memdisk, arguments.pubkeys, @@ -139,26 +138,23 @@ index c1e07c70dc7..6034c51ece4 100644 + arguments.npubkeys, arguments.x509keys, + arguments.nx509keys, arguments.config, arguments.image_target, arguments.note, - arguments.appsig_size, - arguments.comp, arguments.dtb); + + arguments.comp, arguments.appsig_size, diff --git a/util/mkimage.c b/util/mkimage.c -index bd06968decc..5702a00d06f 100644 +index bab12276010..8319e8dfbde 100644 --- a/util/mkimage.c +++ b/util/mkimage.c -@@ -819,8 +819,10 @@ grub_install_get_image_targets_string (void) - void +@@ -867,7 +867,8 @@ void grub_install_generate_image (const char *dir, const char *prefix, FILE *out, const char *outname, char *mods[], -- char *memdisk_path, char **pubkey_paths, + char *memdisk_path, char **pubkey_paths, - size_t npubkeys, char *config_path, -+ char *memdisk_path, -+ char **pubkey_paths, size_t npubkeys, -+ char **x509key_paths, size_t nx509keys, -+ char *config_path, ++ size_t npubkeys, char **x509key_paths, ++ size_t nx509keys, char *config_path, const struct grub_install_image_target_desc *image_target, - int note, size_t appsig_size, grub_compression_t comp, const char *dtb_path) - { -@@ -864,6 +866,19 @@ grub_install_generate_image (const char *dir, const char *prefix, + int note, size_t appsig_size, grub_compression_t comp, + const char *dtb_path, const char *sbat_path, +@@ -913,6 +914,19 @@ grub_install_generate_image (const char *dir, const char *prefix, } } @@ -178,7 +174,7 @@ index bd06968decc..5702a00d06f 100644 if (memdisk_path) { memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512); -@@ -979,7 +994,7 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -1034,7 +1048,7 @@ grub_install_generate_image (const char *dir, const char *prefix, curs = grub_util_get_image_size (pubkey_paths[i]); header = (struct grub_module_header *) (kernel_img + offset); @@ -187,7 +183,7 @@ index bd06968decc..5702a00d06f 100644 header->size = grub_host_to_target32 (curs + sizeof (*header)); offset += sizeof (*header); -@@ -988,6 +1003,26 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -1043,6 +1057,26 @@ grub_install_generate_image (const char *dir, const char *prefix, } } @@ -215,33 +211,34 @@ index bd06968decc..5702a00d06f 100644 { struct grub_module_header *header; diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index de48cd44ccb..5d54c45cb70 100644 +index 55849777eaa..98edc0863f6 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h -@@ -28,7 +28,8 @@ enum - OBJ_TYPE_MEMDISK, - OBJ_TYPE_CONFIG, +@@ -30,7 +30,9 @@ enum OBJ_TYPE_PREFIX, -- OBJ_TYPE_PUBKEY, + OBJ_TYPE_PUBKEY, + OBJ_TYPE_DTB, +- OBJ_TYPE_DISABLE_SHIM_LOCK ++ OBJ_TYPE_DISABLE_SHIM_LOCK, + OBJ_TYPE_GPG_PUBKEY, + OBJ_TYPE_X509_PUBKEY, - OBJ_TYPE_DTB }; + /* The module header. */ diff --git a/include/grub/util/install.h b/include/grub/util/install.h -index eb1b83b6d94..8353bafb00a 100644 +index b3307fef9b4..faecf7b26e2 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h -@@ -63,6 +63,8 @@ - /* TRANSLATORS: "embed" is a verb (command description). "*/ \ - { "pubkey", 'k', N_("FILE"), 0, \ - N_("embed FILE as public key for signature checking"), 0}, \ +@@ -67,6 +67,8 @@ + N_("SBAT metadata"), 0 }, \ + { "disable-shim-lock", GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK, 0, 0, \ + N_("disable shim_lock verifier"), 0 }, \ + { "x509key", 'x', N_("FILE"), 0, \ + N_("embed FILE as an x509 certificate for signature checking"), 0}, \ { "appended-signature-size", GRUB_INSTALL_OPTIONS_APPENDED_SIGNATURE_SIZE,\ "SIZE", 0, N_("Add a note segment reserving SIZE bytes for an appended signature"), \ 1}, \ -@@ -182,8 +184,9 @@ void +@@ -188,8 +190,9 @@ void grub_install_generate_image (const char *dir, const char *prefix, FILE *out, const char *outname, char *mods[], diff --git a/0296-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch b/0189-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch similarity index 100% rename from 0296-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch rename to 0189-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch diff --git a/0297-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch b/0190-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch similarity index 97% rename from 0297-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch rename to 0190-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch index c638457..04bf1df 100644 --- a/0297-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch +++ b/0190-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch @@ -19,9 +19,9 @@ Signed-off-by: Daniel Axtens --- grub-core/commands/appendedsig/asn1util.c | 102 +++ grub-core/commands/appendedsig/pkcs7.c | 305 +++++++++ - grub-core/commands/appendedsig/x509.c | 972 +++++++++++++++++++++++++++ + grub-core/commands/appendedsig/x509.c | 958 +++++++++++++++++++++++++++ grub-core/commands/appendedsig/appendedsig.h | 110 +++ - 4 files changed, 1489 insertions(+) + 4 files changed, 1475 insertions(+) create mode 100644 grub-core/commands/appendedsig/asn1util.c create mode 100644 grub-core/commands/appendedsig/pkcs7.c create mode 100644 grub-core/commands/appendedsig/x509.c @@ -448,10 +448,10 @@ index 00000000000..dc6afe203f7 +} diff --git a/grub-core/commands/appendedsig/x509.c b/grub-core/commands/appendedsig/x509.c new file mode 100644 -index 00000000000..652e4f16870 +index 00000000000..2b38b3670a2 --- /dev/null +++ b/grub-core/commands/appendedsig/x509.c -@@ -0,0 +1,972 @@ +@@ -0,0 +1,958 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2020 IBM Corporation. @@ -758,39 +758,25 @@ index 00000000000..652e4f16870 + goto cleanup; + } + -+ if (grub_strncmp ("utf8String", choice, choice_size) == 0) -+ { -+ result = asn1_read_value (strasn, "utf8String", NULL, &tmp_size); -+ if (result != ASN1_MEM_ERROR) -+ { -+ err = -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "Error reading size of UTF-8 string: %s", -+ asn1_strerror (result)); -+ goto cleanup_choice; -+ } -+ } -+ else if (grub_strncmp("printableString", choice, choice_size) == 0) -+ { -+ result = asn1_read_value (strasn, "printableString", NULL, &tmp_size); -+ if (result != ASN1_MEM_ERROR) -+ { -+ err = -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "Error reading size of UTF-8 string: %s", -+ asn1_strerror (result)); -+ goto cleanup_choice; -+ } -+ } -+ else ++ if (grub_strncmp ("utf8String", choice, choice_size)) + { + err = + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ "Only UTF-8 and printable DirectoryStrings are supported, got %s", ++ "Only UTF-8 DirectoryStrings are supported, got %s", + choice); + goto cleanup_choice; + } + ++ result = asn1_read_value (strasn, "utf8String", NULL, &tmp_size); ++ if (result != ASN1_MEM_ERROR) ++ { ++ err = ++ grub_error (GRUB_ERR_BAD_FILE_TYPE, ++ "Error reading size of UTF-8 string: %s", ++ asn1_strerror (result)); ++ goto cleanup_choice; ++ } ++ + /* read size does not include trailing null */ + tmp_size++; + @@ -803,13 +789,13 @@ index 00000000000..652e4f16870 + goto cleanup_choice; + } + -+ result = asn1_read_value (strasn, choice, *string, &tmp_size); ++ result = asn1_read_value (strasn, "utf8String", *string, &tmp_size); + if (result != ASN1_SUCCESS) + { + err = + grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "Error reading out %s in DirectoryString: %s", -+ choice, asn1_strerror (result)); ++ "Error reading out UTF-8 string in DirectoryString: %s", ++ asn1_strerror (result)); + grub_free (*string); + goto cleanup_choice; + } diff --git a/0190-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch b/0190-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch deleted file mode 100644 index 2df15bf..0000000 --- a/0190-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 4 Nov 2019 17:33:30 +0100 -Subject: [PATCH] blscfg: Add support for sorting the plus ('+') higher than - base version - -Handle plus separator. Concept is the same as tilde, except that if one of -the strings ends (base version), the other is considered as higher version. - -A plus character is used for example by the Linux kernel build system to -denote that is the base version plus some changes on top of it. - -Currently for example rpmvercmp("5.3.0", "5.3.0+") will return 0 even when -the two versions are not the same. - -Resolves: rhbz#1767395 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 19 +++++++++++++++++-- - 1 file changed, 17 insertions(+), 2 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index d78cff79f97..83b33c1cd93 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -163,8 +163,8 @@ static int vercmp(const char * a, const char * b) - - /* loop through each version segment of str1 and str2 and compare them */ - while (*one || *two) { -- while (*one && !grub_isalnum(*one) && *one != '~') one++; -- while (*two && !grub_isalnum(*two) && *two != '~') two++; -+ while (*one && !grub_isalnum(*one) && *one != '~' && *one != '+') one++; -+ while (*two && !grub_isalnum(*two) && *two != '~' && *two != '+') two++; - - /* handle the tilde separator, it sorts before everything else */ - if (*one == '~' || *two == '~') { -@@ -175,6 +175,21 @@ static int vercmp(const char * a, const char * b) - continue; - } - -+ /* -+ * Handle plus separator. Concept is the same as tilde, -+ * except that if one of the strings ends (base version), -+ * the other is considered as higher version. -+ */ -+ if (*one == '+' || *two == '+') { -+ if (!*one) return -1; -+ if (!*two) return 1; -+ if (*one != '+') goto_return (1); -+ if (*two != '+') goto_return (-1); -+ one++; -+ two++; -+ continue; -+ } -+ - /* If we ran to the end of either, we are finished with the loop */ - if (!(*one && *two)) break; - diff --git a/0191-Fix-savedefault-with-blscfg.patch b/0191-Fix-savedefault-with-blscfg.patch deleted file mode 100644 index 51d5b82..0000000 --- a/0191-Fix-savedefault-with-blscfg.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Fritz Elfert -Date: Mon, 13 Jan 2020 19:29:58 +0100 -Subject: [PATCH] Fix savedefault with blscfg - -The GRUB_SAVEDEFAULT option was ignored on a BLS configuration. Fix it by -making the menu entries populated from the BLS files to call savedefault -if a save_default environment variable has been set to "true". - -This variable is set by grub2-mkconfig to the value in GRUB_SAVEDEFAULT. ---- - grub-core/commands/blscfg.c | 5 ++++- - util/grub.d/10_linux.in | 4 ++++ - 2 files changed, 8 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 83b33c1cd93..069db721bec 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -889,11 +889,14 @@ static void create_entry (struct bls_entry *entry) - - grub_dprintf ("blscfg2", "devicetree %s for id:\"%s\"\n", dt, id); - -- src = grub_xasprintf ("load_video\n" -+ const char *sdval = grub_env_get("save_default"); -+ bool savedefault = ((NULL != sdval) && (grub_strcmp(sdval, "true") == 0)); -+ src = grub_xasprintf ("%sload_video\n" - "set gfxpayload=keep\n" - "insmod gzio\n" - "linux %s%s%s%s\n" - "%s%s", -+ savedefault ? "savedefault\n" : "", - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", - initrd ? initrd : "", dt ? dt : ""); - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 21a6915dca3..b70dca27567 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -152,6 +152,10 @@ EOF - if [ -n "${GRUB_DEFAULT_DTB}" ]; then - ${grub_editenv} - set devicetree="${GRUB_DEFAULT_DTB}" - fi -+ -+ if [ -n "${GRUB_SAVEDEFAULT}" ]; then -+ ${grub_editenv} - set save_default="${GRUB_SAVEDEFAULT}" -+ fi - fi - - exit 0 diff --git a/0298-appended-signatures-support-verifying-appended-signa.patch b/0191-appended-signatures-support-verifying-appended-signa.patch similarity index 88% rename from 0298-appended-signatures-support-verifying-appended-signa.patch rename to 0191-appended-signatures-support-verifying-appended-signa.patch index f379d68..262efc0 100644 --- a/0298-appended-signatures-support-verifying-appended-signa.patch +++ b/0191-appended-signatures-support-verifying-appended-signa.patch @@ -7,35 +7,31 @@ Building on the parsers and the ability to embed x509 certificates, as well as the existing gcrypt functionality, add a module for verifying appended signatures. -This includes: +This includes a verifier that requires that Linux kernels and grub modules +have appended signatures, and commands to manage the list of trusted +certificates for verification. - - a verifier that requires that kernels and grub modules have appended - signatures. It shares lots of logic with shim-lock verifier about what - files need to be verified and what modules are unsafe to have loaded. +Verification must be enabled by setting check_appended_signatures. If +GRUB is locked down when the module is loaded, verification will be +enabled and locked automatically. - - commands to manage the list of trusted certificates for verification. - -Similar to the PGP verifier, if a certificate is embedded in the core -image, verification will be enforced unless disabled on the the grub -command line or by load_env. - -Thus, as with the PGP verifier, it is not a complete secure-boot solution: -other mechanisms must be used to ensure that a user cannot drop to the -grub shell and disable verification. +As with the PGP verifier, it is not a complete secure-boot solution: +other mechanisms, such as a password or lockdown, must be used to ensure +that a user cannot drop to the grub shell and disable verification. Signed-off-by: Daniel Axtens --- grub-core/Makefile.core.def | 12 + - grub-core/commands/appendedsig/appendedsig.c | 644 +++++++++++++++++++++++++++ + grub-core/commands/appendedsig/appendedsig.c | 645 +++++++++++++++++++++++++++ include/grub/file.h | 2 + - 3 files changed, 658 insertions(+) + 3 files changed, 659 insertions(+) create mode 100644 grub-core/commands/appendedsig/appendedsig.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 78071360529..30bd9a4a587 100644 +index b4aaccf7b57..77321d218c8 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -977,6 +977,18 @@ module = { +@@ -980,6 +980,18 @@ module = { cppflags = '-I$(srcdir)/lib/posix_wrap'; }; @@ -52,17 +48,17 @@ index 78071360529..30bd9a4a587 100644 +}; + module = { - name = verifiers; - common = commands/verifiers.c; + name = hdparm; + common = commands/hdparm.c; diff --git a/grub-core/commands/appendedsig/appendedsig.c b/grub-core/commands/appendedsig/appendedsig.c new file mode 100644 -index 00000000000..1fbc942254a +index 00000000000..dc294cd339e --- /dev/null +++ b/grub-core/commands/appendedsig/appendedsig.c -@@ -0,0 +1,644 @@ +@@ -0,0 +1,645 @@ +/* + * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2020 IBM Corporation. ++ * Copyright (C) 2020-2021 IBM Corporation. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by @@ -94,6 +90,7 @@ index 00000000000..1fbc942254a +#include +#include +#include ++#include + +#include "appendedsig.h" + @@ -153,12 +150,34 @@ index 00000000000..1fbc942254a + +static int check_sigs = 0; + ++static const char * ++grub_env_read_sec (struct grub_env_var *var __attribute__ ((unused)), ++ const char *val __attribute__ ((unused))) ++{ ++ if (check_sigs == 2) ++ return "forced"; ++ else if (check_sigs == 1) ++ return "enforce"; ++ else ++ return "no"; ++} ++ +static char * +grub_env_write_sec (struct grub_env_var *var __attribute__((unused)), + const char *val) +{ -+ check_sigs = (*val == '1') || (*val == 'e'); -+ return grub_strdup (check_sigs ? "enforce" : "no"); ++ /* Do not allow the value to be changed if set to forced */ ++ if (check_sigs == 2) ++ return grub_strdup ("forced"); ++ ++ if ((*val == '2') || (*val == 'f')) ++ check_sigs = 2; ++ else if ((*val == '1') || (*val == 'e')) ++ check_sigs = 1; ++ else if ((*val == '0') || (*val == 'n')) ++ check_sigs = 0; ++ ++ return grub_strdup (grub_env_read_sec (NULL, NULL)); +} + +static grub_err_t @@ -513,12 +532,11 @@ index 00000000000..1fbc942254a +} + +static grub_err_t -+appendedsig_init (grub_file_t io, enum grub_file_type type, ++appendedsig_init (grub_file_t io __attribute__((unused)), ++ enum grub_file_type type, + void **context __attribute__((unused)), + enum grub_verify_flags *flags) +{ -+ const char *dangerous_mod; -+ + if (!check_sigs) + { + *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION; @@ -527,20 +545,6 @@ index 00000000000..1fbc942254a + + switch (type & GRUB_FILE_TYPE_MASK) + { -+ case GRUB_FILE_TYPE_GRUB_MODULE: -+ if (grub_is_dangerous_module (io)) -+ return grub_error (GRUB_ERR_ACCESS_DENIED, -+ N_("module cannot be loaded in appended signature mode: %s"), -+ io->name); -+ -+ *flags = GRUB_VERIFY_FLAGS_SINGLE_CHUNK; -+ return GRUB_ERR_NONE; -+ -+ case GRUB_FILE_TYPE_ACPI_TABLE: -+ case GRUB_FILE_TYPE_DEVICE_TREE_IMAGE: -+ *flags = GRUB_VERIFY_FLAGS_DEFER_AUTH; -+ return GRUB_ERR_NONE; -+ + case GRUB_FILE_TYPE_CERTIFICATE_TRUST: + /* + * This is a certificate to add to trusted keychain. @@ -553,25 +557,28 @@ index 00000000000..1fbc942254a + /* Fall through */ + + case GRUB_FILE_TYPE_LINUX_KERNEL: -+ case GRUB_FILE_TYPE_MULTIBOOT_KERNEL: -+ case GRUB_FILE_TYPE_BSD_KERNEL: -+ case GRUB_FILE_TYPE_XNU_KERNEL: -+ case GRUB_FILE_TYPE_PLAN9_KERNEL: -+ -+ dangerous_mod = grub_dangerous_module_loaded (); -+ if (dangerous_mod) -+ return grub_error (GRUB_ERR_ACCESS_DENIED, -+ N_("cannot proceed due to dangerous module in memory: %s"), -+ dangerous_mod); -+ ++ case GRUB_FILE_TYPE_GRUB_MODULE: ++ /* ++ * Appended signatures are only defined for ELF binaries. ++ * Out of an abundance of caution, we only verify Linux kernels and ++ * GRUB modules at this point. ++ */ + *flags = GRUB_VERIFY_FLAGS_SINGLE_CHUNK; + return GRUB_ERR_NONE; + -+ default: ++ case GRUB_FILE_TYPE_ACPI_TABLE: ++ case GRUB_FILE_TYPE_DEVICE_TREE_IMAGE: + /* -+ * powerpc only supports the linux loader. If you support more, -+ * (especially chain loaded binaries) make sure they're checked! ++ * It is possible to use appended signature verification without ++ * lockdown - like the PGP verifier. When combined with an embedded ++ * config file in a signed grub binary, this could still be a meaningful ++ * secure-boot chain - so long as it isn't subverted by something like a ++ * rouge ACPI table or DT image. Defer them explicitly. + */ ++ *flags = GRUB_VERIFY_FLAGS_DEFER_AUTH; ++ return GRUB_ERR_NONE; ++ ++ default: + *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION; + return GRUB_ERR_NONE; + } @@ -609,19 +616,15 @@ index 00000000000..1fbc942254a +{ + int rc; + struct grub_module_header *header; -+ const char *val; + -+ val = grub_env_get ("check_appended_signatures"); -+ grub_dprintf ("appendedsig", "check_appended_signatures='%s'\n", val); -+ -+ if (val && (val[0] == '1' || val[0] == 'e')) -+ check_sigs = 1; -+ else -+ check_sigs = 0; ++ /* If in lockdown, immediately enter forced mode */ ++ if (grub_is_lockdown () == GRUB_LOCKDOWN_ENABLED) ++ check_sigs = 2; + + grub_trusted_key = NULL; + -+ grub_register_variable_hook ("check_appended_signatures", 0, ++ grub_register_variable_hook ("check_appended_signatures", ++ grub_env_read_sec, + grub_env_write_sec); + grub_env_export ("check_appended_signatures"); + @@ -665,12 +668,6 @@ index 00000000000..1fbc942254a + grub_trusted_key = pk; + } + -+ if (!val || val[0] == '\0') -+ { -+ grub_env_set ("check_appended_signatures", -+ grub_trusted_key ? "enforce" : "no"); -+ } -+ + cmd_trust = + grub_register_command ("trust_certificate", grub_cmd_trust, + N_("X509_CERTIFICATE"), diff --git a/0299-appended-signatures-verification-tests.patch b/0192-appended-signatures-verification-tests.patch similarity index 86% rename from 0299-appended-signatures-verification-tests.patch rename to 0192-appended-signatures-verification-tests.patch index 3b2d9e9..8364a90 100644 --- a/0299-appended-signatures-verification-tests.patch +++ b/0192-appended-signatures-verification-tests.patch @@ -9,18 +9,18 @@ of commands and behaviours. Signed-off-by: Daniel Axtens --- grub-core/Makefile.core.def | 6 + - grub-core/tests/appended_signature_test.c | 281 +++++++++++++++ + grub-core/tests/appended_signature_test.c | 250 ++++++++++++++++ grub-core/tests/lib/functional_test.c | 1 + - grub-core/tests/appended_signatures.h | 557 ++++++++++++++++++++++++++++++ - 4 files changed, 845 insertions(+) + grub-core/tests/appended_signatures.h | 483 ++++++++++++++++++++++++++++++ + 4 files changed, 740 insertions(+) create mode 100644 grub-core/tests/appended_signature_test.c create mode 100644 grub-core/tests/appended_signatures.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 30bd9a4a587..640de1b299b 100644 +index 77321d218c8..6bddc841b85 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2138,6 +2138,12 @@ module = { +@@ -2161,6 +2161,12 @@ module = { common = tests/setjmp_test.c; }; @@ -35,10 +35,10 @@ index 30bd9a4a587..640de1b299b 100644 common = tests/signature_test.c; diff --git a/grub-core/tests/appended_signature_test.c b/grub-core/tests/appended_signature_test.c new file mode 100644 -index 00000000000..88a485200d8 +index 00000000000..bb29a85c9bb --- /dev/null +++ b/grub-core/tests/appended_signature_test.c -@@ -0,0 +1,281 @@ +@@ -0,0 +1,250 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2020 IBM Corporation. @@ -136,23 +136,6 @@ index 00000000000..88a485200d8 + .get_contents = get_certificate2_der +}; + -+static char * -+get_certificate_printable_der (grub_size_t * sz) -+{ -+ char *ret; -+ *sz = certificate_printable_der_len; -+ ret = grub_malloc (*sz); -+ if (ret) -+ grub_memcpy (ret, certificate_printable_der, *sz); -+ return ret; -+} -+ -+static struct grub_procfs_entry certificate_printable_der_entry = { -+ .name = "certificate_printable.der", -+ .get_contents = get_certificate_printable_der -+}; -+ -+ +static void +do_verify (const char *f, int is_valid) +{ @@ -188,16 +171,12 @@ index 00000000000..88a485200d8 + grub_command_t cmd_trust, cmd_distrust; + char *trust_args[] = { (char *) "(proc)/certificate.der", NULL }; + char *trust_args2[] = { (char *) "(proc)/certificate2.der", NULL }; -+ char *trust_args_printable[] = { (char *) "(proc)/certificate_printable.der", -+ NULL }; + char *distrust_args[] = { (char *) "1", NULL }; + char *distrust2_args[] = { (char *) "2", NULL }; + grub_err_t err; + + grub_procfs_register ("certificate.der", &certificate_der_entry); + grub_procfs_register ("certificate2.der", &certificate2_der_entry); -+ grub_procfs_register ("certificate_printable.der", -+ &certificate_printable_der_entry); + + cmd_trust = grub_command_find ("trust_certificate"); + if (!cmd_trust) @@ -305,18 +284,8 @@ index 00000000000..88a485200d8 + grub_errno, grub_errmsg); + DO_TEST (hi_signed_2nd, 0); + -+ /* -+ * Lastly, check a certificate that uses printableString rather than -+ * utf8String loads properly. -+ */ -+ err = (cmd_trust->func) (cmd_trust, 1, trust_args_printable); -+ grub_test_assert (err == GRUB_ERR_NONE, -+ "distrusting printable certificate failed: %d: %s", -+ grub_errno, grub_errmsg); -+ + grub_procfs_unregister (&certificate_der_entry); + grub_procfs_unregister (&certificate2_der_entry); -+ grub_procfs_unregister (&certificate_printable_der_entry); +} + +GRUB_FUNCTIONAL_TEST (appended_signature_test, appended_signature_test); @@ -334,10 +303,10 @@ index 96781fb39b5..403fa5c789a 100644 grub_dl_load ("ctz_test"); diff --git a/grub-core/tests/appended_signatures.h b/grub-core/tests/appended_signatures.h new file mode 100644 -index 00000000000..aa3dc6278e3 +index 00000000000..d5b56f74ad9 --- /dev/null +++ b/grub-core/tests/appended_signatures.h -@@ -0,0 +1,557 @@ +@@ -0,0 +1,483 @@ +unsigned char certificate_der[] = { + 0x30, 0x82, 0x03, 0x88, 0x30, 0x82, 0x02, 0x70, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x14, 0x25, 0x2e, 0xb8, 0xfd, 0x12, 0x62, 0x2e, 0xcd, 0x5d, @@ -821,77 +790,3 @@ index 00000000000..aa3dc6278e3 + 0x65, 0x64, 0x7e, 0x0a +}; +unsigned int hi_signed_2nd_len = 736; -+ -+unsigned char certificate_printable_der[] = { -+ 0x30, 0x82, 0x03, 0x39, 0x30, 0x82, 0x02, 0x21, 0xa0, 0x03, 0x02, 0x01, -+ 0x02, 0x02, 0x09, 0x00, 0xde, 0xf6, 0x22, 0xc4, 0xf2, 0xf1, 0x86, 0x02, -+ 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, -+ 0x0b, 0x05, 0x00, 0x30, 0x2a, 0x31, 0x28, 0x30, 0x26, 0x06, 0x03, 0x55, -+ 0x04, 0x03, 0x13, 0x1f, 0x52, 0x65, 0x64, 0x20, 0x48, 0x61, 0x74, 0x20, -+ 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x42, 0x6f, 0x6f, 0x74, 0x20, -+ 0x43, 0x41, 0x20, 0x32, 0x20, 0x28, 0x62, 0x65, 0x74, 0x61, 0x29, 0x30, -+ 0x1e, 0x17, 0x0d, 0x31, 0x34, 0x31, 0x30, 0x33, 0x31, 0x31, 0x34, 0x31, -+ 0x39, 0x32, 0x33, 0x5a, 0x17, 0x0d, 0x33, 0x37, 0x31, 0x30, 0x32, 0x35, -+ 0x31, 0x34, 0x31, 0x39, 0x32, 0x33, 0x5a, 0x30, 0x2f, 0x31, 0x2d, 0x30, -+ 0x2b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x24, 0x52, 0x65, 0x64, 0x20, -+ 0x48, 0x61, 0x74, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x42, -+ 0x6f, 0x6f, 0x74, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, -+ 0x33, 0x20, 0x28, 0x62, 0x65, 0x74, 0x61, 0x29, 0x30, 0x82, 0x01, 0x22, -+ 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, -+ 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, -+ 0x02, 0x82, 0x01, 0x01, 0x00, 0xbd, 0xda, 0xa1, 0xed, 0x8d, 0x8e, 0x15, -+ 0x5c, 0xf8, 0x01, 0x77, 0x48, 0x4a, 0x60, 0x96, 0xf9, 0x27, 0xfa, 0xe2, -+ 0xb1, 0x69, 0x0f, 0x51, 0x19, 0x52, 0x7e, 0xc4, 0x34, 0x8e, 0xe1, 0x9b, -+ 0x9c, 0xa4, 0xb1, 0x5c, 0xd6, 0x81, 0x98, 0x78, 0xfe, 0xa9, 0xe5, 0x0b, -+ 0x00, 0xba, 0x9c, 0x64, 0x7e, 0xc7, 0xcc, 0x72, 0xb1, 0x73, 0x4b, 0x11, -+ 0x07, 0x52, 0xf0, 0x20, 0x96, 0x8b, 0x99, 0x39, 0xde, 0xdb, 0xfa, 0x3d, -+ 0x45, 0xe2, 0x98, 0x7b, 0x0c, 0x41, 0xe4, 0x0c, 0xb5, 0x5d, 0x92, 0x74, -+ 0x39, 0x96, 0xe1, 0x97, 0x97, 0xa1, 0xad, 0x2e, 0xcc, 0xd0, 0x1b, 0x4d, -+ 0x9d, 0xbd, 0x3e, 0xa9, 0x36, 0x8e, 0xcc, 0xc7, 0x5f, 0x6a, 0x7d, 0x39, -+ 0x5e, 0x0b, 0x8d, 0xca, 0xe4, 0x83, 0xe9, 0x3b, 0x5c, 0x86, 0x47, 0xd4, -+ 0xba, 0x7d, 0x98, 0x26, 0xa1, 0xf4, 0xe8, 0x90, 0x6b, 0x0f, 0xf1, 0x6b, -+ 0x8c, 0xe3, 0xa2, 0x80, 0x3c, 0x96, 0xf1, 0x0a, 0xb6, 0x66, 0xc0, 0x4b, -+ 0x61, 0xf7, 0x74, 0xcd, 0xd3, 0x7b, 0x8e, 0x5e, 0x39, 0xda, 0x99, 0x20, -+ 0x33, 0x93, 0xd3, 0xf0, 0x7f, 0xad, 0x35, 0xe9, 0x88, 0x8d, 0x9c, 0xbf, -+ 0x65, 0xf1, 0x47, 0x02, 0xf9, 0x7c, 0xed, 0x27, 0x5f, 0x4a, 0x65, 0x3c, -+ 0xcf, 0x5f, 0x0e, 0x88, 0x95, 0x74, 0xde, 0xfb, 0x9e, 0x2e, 0x91, 0x9b, -+ 0x45, 0x37, 0xc8, 0x85, 0xff, 0xe3, 0x41, 0x70, 0xfe, 0xd5, 0xef, 0x0e, -+ 0x82, 0x22, 0x08, 0xb7, 0x3b, 0x44, 0x3e, 0xdc, 0x5b, 0x7f, 0xba, 0xbf, -+ 0xe6, 0x58, 0x9d, 0x02, 0x6e, 0x75, 0xbf, 0x50, 0xec, 0xcf, 0x3f, 0xa5, -+ 0x91, 0x0a, 0xe2, 0x59, 0x2c, 0xc3, 0xe7, 0x05, 0x03, 0xe8, 0xf2, 0x6f, -+ 0x2a, 0x04, 0x68, 0x9a, 0x31, 0x32, 0x8f, 0x04, 0x35, 0xcd, 0x1f, 0x34, -+ 0xcc, 0x4f, 0x79, 0x5a, 0x99, 0x8d, 0x9d, 0x5c, 0xf5, 0x02, 0x03, 0x01, -+ 0x00, 0x01, 0xa3, 0x5d, 0x30, 0x5b, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, -+ 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0b, 0x06, 0x03, -+ 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x07, 0x80, 0x30, 0x1d, 0x06, -+ 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x65, 0xc5, 0xbe, 0xca, -+ 0xe6, 0x59, 0x6a, 0xfd, 0x6c, 0x71, 0xc4, 0xa7, 0x98, 0xc6, 0x25, 0x8d, -+ 0x7b, 0x67, 0x05, 0xd0, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, -+ 0x18, 0x30, 0x16, 0x80, 0x14, 0x81, 0xf8, 0xee, 0x47, 0x5c, 0x3e, 0xed, -+ 0xfb, 0xce, 0xa5, 0x84, 0xbe, 0xd7, 0xae, 0xdb, 0xd3, 0x7d, 0x64, 0xb3, -+ 0x2a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, -+ 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x66, 0x1e, 0x3d, -+ 0x1d, 0x53, 0x33, 0xde, 0x4e, 0xc7, 0xc4, 0xf4, 0xdf, 0xda, 0x18, 0x19, -+ 0x8a, 0xa9, 0xff, 0xe2, 0x63, 0x2b, 0xbe, 0xf2, 0x61, 0x63, 0xe2, 0xf6, -+ 0xed, 0x47, 0x1a, 0x71, 0x02, 0xec, 0x2a, 0xef, 0x89, 0x77, 0xe3, 0xfd, -+ 0x86, 0x69, 0xf1, 0x3f, 0x0d, 0xf9, 0x6e, 0xf9, 0x3b, 0xad, 0x26, 0x47, -+ 0xb7, 0xf2, 0x0d, 0xad, 0x23, 0xa3, 0x67, 0x3b, 0xcb, 0x6d, 0x9e, 0x03, -+ 0x0f, 0xbc, 0x69, 0x73, 0x9f, 0xd4, 0xa5, 0x0f, 0x6f, 0xf8, 0xab, 0x4d, -+ 0x36, 0xd1, 0xe0, 0xe0, 0x5d, 0x20, 0x43, 0x90, 0xc4, 0x65, 0x61, 0x93, -+ 0xe2, 0x0f, 0x51, 0x59, 0x0a, 0xf7, 0x88, 0x70, 0x57, 0xb9, 0x04, 0xa9, -+ 0x32, 0x57, 0x9c, 0xb3, 0x57, 0x38, 0x8b, 0x8e, 0x46, 0xc8, 0x32, 0x6c, -+ 0xb4, 0xf3, 0x96, 0x7f, 0x4b, 0xf0, 0x88, 0xf9, 0x7f, 0xe2, 0x71, 0xe1, -+ 0x8b, 0xe2, 0x14, 0xf1, 0x4b, 0x25, 0x00, 0x48, 0x1c, 0x7e, 0xe5, 0x8d, -+ 0x65, 0x2d, 0xeb, 0x72, 0x4f, 0x92, 0x44, 0xf3, 0xe6, 0xe0, 0xd0, 0xdf, -+ 0x85, 0xa8, 0x13, 0x4a, 0xfb, 0x99, 0xca, 0x14, 0x2c, 0x97, 0x80, 0x93, -+ 0x27, 0xd3, 0x20, 0xf8, 0x6d, 0x29, 0x28, 0x2c, 0xb9, 0x77, 0xea, 0xb1, -+ 0x63, 0xbd, 0x7d, 0x53, 0xfd, 0x4a, 0x62, 0x64, 0x0b, 0x98, 0xa8, 0xae, -+ 0x11, 0xfc, 0x6e, 0x8d, 0x63, 0xd4, 0x15, 0x55, 0xc6, 0x4c, 0x74, 0xf5, -+ 0x5f, 0xa0, 0xb9, 0x2c, 0x2d, 0x9a, 0x7a, 0x87, 0x6e, 0xf0, 0x5e, 0x25, -+ 0xed, 0xfc, 0xd8, 0xc4, 0x34, 0x33, 0x32, 0xad, 0x01, 0xd4, 0x4b, 0x49, -+ 0x51, 0xc2, 0x07, 0x7f, 0x90, 0x6d, 0xea, 0xf5, 0x4c, 0x41, 0x71, 0x64, -+ 0xeb, 0x1f, 0x29, 0xa3, 0x1f, 0x64, 0xa2, 0x1e, 0x0e, 0x6f, 0xa1, 0x67, -+ 0x99, 0x8d, 0x98, 0x1c, 0xb8, 0x53, 0x9d, 0x30, 0x1d, 0xae, 0x32, 0x56, -+ 0xd2 -+}; -+unsigned int certificate_printable_der_len = 829; diff --git a/0300-appended-signatures-documentation.patch b/0193-appended-signatures-documentation.patch similarity index 76% rename from 0300-appended-signatures-documentation.patch rename to 0193-appended-signatures-documentation.patch index 7c1170a..c907633 100644 --- a/0300-appended-signatures-documentation.patch +++ b/0193-appended-signatures-documentation.patch @@ -1,23 +1,22 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 8 Feb 2021 19:30:54 +0100 +From: Daniel Axtens +Date: Thu, 1 Oct 2020 13:02:09 +1000 Subject: [PATCH] appended signatures: documentation This explains how appended signatures can be used to form part of a secure boot chain, and documents the commands and variables introduced. -(docs: s/grub/grub2/) Signed-off-by: Daniel Axtens --- - docs/grub.texi | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 174 insertions(+), 15 deletions(-) + docs/grub.texi | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 182 insertions(+), 17 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi -index 7fc2a62a4f8..7fe365414e4 100644 +index 691ffaa1861..7b5d7800418 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -3160,6 +3160,7 @@ These variables have special meaning to GRUB. +@@ -3216,6 +3216,7 @@ These variables have special meaning to GRUB. @menu * biosnum:: @@ -25,7 +24,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 * check_signatures:: * chosen:: * cmdpath:: -@@ -3219,11 +3220,18 @@ For an alternative approach which also changes BIOS drive mappings for the +@@ -3275,11 +3276,18 @@ For an alternative approach which also changes BIOS drive mappings for the chain-loaded system, @pxref{drivemap}. @@ -46,7 +45,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 @node chosen @subsection chosen -@@ -3937,6 +3945,7 @@ you forget a command, you can run the command @command{help} +@@ -3994,6 +4002,7 @@ you forget a command, you can run the command @command{help} * date:: Display or set current date and time * devicetree:: Load a device tree blob * distrust:: Remove a pubkey from trusted keys @@ -54,7 +53,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 * drivemap:: Map a drive to another * echo:: Display a line of text * eval:: Evaluate agruments as GRUB commands -@@ -3953,6 +3962,7 @@ you forget a command, you can run the command @command{help} +@@ -4010,6 +4019,7 @@ you forget a command, you can run the command @command{help} * keystatus:: Check key modifier status * linux:: Load a Linux kernel * linux16:: Load a Linux kernel (16-bit mode) @@ -62,19 +61,18 @@ index 7fc2a62a4f8..7fe365414e4 100644 * list_env:: List variables in environment block * list_trusted:: List trusted public keys * load_env:: Load variables from environment block -@@ -3990,9 +4000,11 @@ you forget a command, you can run the command @command{help} +@@ -4047,8 +4057,10 @@ you forget a command, you can run the command @command{help} * test:: Check file types and compare values * true:: Do nothing, successfully * trust:: Add public key to list of trusted keys +* trust_certificate:: Add an x509 certificate to the list of trusted certificates * unset:: Unset an environment variable - * uppermem:: Set the upper memory size @comment * vbeinfo:: List available video modes +* verify_appended:: Verify appended digital signature * verify_detached:: Verify detached digital signature * videoinfo:: List available video modes @comment * xen_*:: Xen boot commands for AArch64 -@@ -4284,9 +4296,28 @@ These keys are used to validate signatures when environment variable +@@ -4373,9 +4385,28 @@ These keys are used to validate signatures when environment variable @code{check_signatures} is set to @code{enforce} (@pxref{check_signatures}), and by some invocations of @command{verify_detached} (@pxref{verify_detached}). @xref{Using @@ -94,17 +92,17 @@ index 7fc2a62a4f8..7fe365414e4 100644 +@command{list_certificates} (@pxref{list_certificates}). + +These certificates are used to validate appended signatures when environment -+variable @code{check_appended_signatures} is set to @code{enforce} -+(@pxref{check_appended_signatures}), and by @command{verify_appended} -+(@pxref{verify_appended}). See @xref{Using appended signatures} for more -+information. ++variable @code{check_appended_signatures} is set to @code{enforce} or ++@code{forced} (@pxref{check_appended_signatures}), and by ++@command{verify_appended} (@pxref{verify_appended}). See ++@xref{Using appended signatures} for more information. +@end deffn + + @node drivemap @subsection drivemap -@@ -4544,6 +4575,21 @@ This command is only available on x86 systems. +@@ -4633,6 +4664,21 @@ This command is only available on x86 systems. @end deffn @@ -126,7 +124,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 @node list_env @subsection list_env -@@ -4563,7 +4609,7 @@ The output is in GPG's v4 key fingerprint format (i.e., the output of +@@ -4652,7 +4698,7 @@ The output is in GPG's v4 key fingerprint format (i.e., the output of @code{gpg --fingerprint}). The least significant four bytes (last eight hexadecimal digits) can be used as an argument to @command{distrust} (@pxref{distrust}). @@ -135,7 +133,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 these keys. @end deffn -@@ -4598,8 +4644,12 @@ When used with care, @option{--skip-sig} and the whitelist enable an +@@ -4687,8 +4733,13 @@ When used with care, @option{--skip-sig} and the whitelist enable an administrator to configure a system to boot only signed configurations, but to allow the user to select from among multiple configurations, and to enable ``one-shot'' boot attempts and @@ -145,11 +143,12 @@ index 7fc2a62a4f8..7fe365414e4 100644 + +Extra care should be taken when combining this command with appended signatures +(@pxref{Using appended signatures}), as this file is not validated by an -+appended signature and could set @code{check_appended_signatures=no}. ++appended signature and could set @code{check_appended_signatures=no} if GRUB is ++not in @pxref{Lockdown} mode. @end deffn -@@ -4903,7 +4953,7 @@ read. It is possible to modify a digitally signed environment block +@@ -4984,7 +5035,7 @@ read. It is possible to modify a digitally signed environment block file from within GRUB using this command, such that its signature will no longer be valid on subsequent boots. Care should be taken in such advanced configurations to avoid rendering the system @@ -158,7 +157,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 @end deffn -@@ -5228,11 +5278,31 @@ signatures when environment variable @code{check_signatures} is set to +@@ -5384,11 +5435,32 @@ signatures when environment variable @code{check_signatures} is set to must itself be properly signed. The @option{--skip-sig} option can be used to disable signature-checking when reading @var{pubkey_file} itself. It is expected that @option{--skip-sig} is useful for testing @@ -175,14 +174,15 @@ index 7fc2a62a4f8..7fe365414e4 100644 +Read an DER-formatted x509 certificate from the file @var{x509_certificate} +and add it to GRUB's internal list of trusted x509 certificates. These +certificates are used to validate appended signatures when the environment -+variable @code{check_appended_signatures} is set to @code{enforce}. ++variable @code{check_appended_signatures} is set to @code{enforce} or ++@code{forced}. + -+Note that if @code{check_appended_signatures} is set to @code{enforce} -+when @command{trust_certificate} is executed, then @var{x509_certificate} -+must itself bear an appended signature. (It is not sufficient that -+@var{x509_certificate} be signed by a trusted certificate according to the -+x509 rules: grub does not include support for validating signatures within x509 -+certificates themselves.) ++Note that if @code{check_appended_signatures} is set to @code{enforce} or ++@code{forced} when @command{trust_certificate} is executed, then ++@var{x509_certificate} must itself bear an appended signature. (It is not ++sufficient that @var{x509_certificate} be signed by a trusted certificate ++according to the x509 rules: grub does not include support for validating ++signatures within x509 certificates themselves.) + +See @xref{Using appended signatures} for more information. +@end deffn @@ -191,7 +191,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 @node unset @subsection unset -@@ -5257,6 +5327,18 @@ only on PC BIOS platforms. +@@ -5407,6 +5479,18 @@ only on PC BIOS platforms. @end deffn @end ignore @@ -210,7 +210,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 @node verify_detached @subsection verify_detached -@@ -5275,7 +5357,7 @@ tried. +@@ -5425,7 +5509,7 @@ tried. Exit code @code{$?} is set to 0 if the signature validates successfully. If validation fails, it is set to a non-zero value. @@ -219,25 +219,29 @@ index 7fc2a62a4f8..7fe365414e4 100644 @end deffn @node videoinfo -@@ -5636,11 +5718,12 @@ environment variables and commands are listed in the same order. +@@ -5808,13 +5892,14 @@ environment variables and commands are listed in the same order. @chapter Security @menu -* Authentication and authorisation:: Users and access control -* Using digital signatures:: Booting digitally signed code --* Signing GRUB itself:: Ensuring the integrity of the GRUB core image -* UEFI secure boot and shim:: Booting digitally signed PE files +-* Secure Boot Advanced Targeting:: Embedded information for generation number based revocation -* Measured Boot:: Measuring boot components +-* Lockdown:: Lockdown when booting on a secure setup +-* Signing GRUB itself:: Ensuring the integrity of the GRUB core image +* Authentication and authorisation:: Users and access control +* Using GPG-style digital signatures:: Booting digitally signed code +* Using appended signatures:: An alternative approach to booting digitally signed code -+* Signing GRUB itself:: Ensuring the integrity of the GRUB core image +* UEFI secure boot and shim:: Booting digitally signed PE files ++* Secure Boot Advanced Targeting:: Embedded information for generation number based revocation +* Measured Boot:: Measuring boot components ++* Lockdown:: Lockdown when booting on a secure setup ++* Signing GRUB itself:: Ensuring the integrity of the GRUB core image @end menu @node Authentication and authorisation -@@ -5713,8 +5796,8 @@ generating configuration files with authentication. You can use +@@ -5888,8 +5973,8 @@ generating configuration files with authentication. You can use adding @kbd{set superusers=} and @kbd{password} or @kbd{password_pbkdf2} commands. @@ -248,7 +252,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 GRUB's @file{core.img} can optionally provide enforcement that all files subsequently read from disk are covered by a valid digital signature. -@@ -5797,6 +5880,82 @@ or BIOS) configuration to cause the machine to boot from a different +@@ -5982,6 +6067,86 @@ or BIOS) configuration to cause the machine to boot from a different (attacker-controlled) device. GRUB is at best only one link in a secure boot chain. @@ -264,11 +268,7 @@ index 7fc2a62a4f8..7fe365414e4 100644 +~Module signature appended~\n +@end example + -+where @code{\n} represents the carriage-return character, @code{0x0a}. -+ -+To enable appended signature verification, load the appendedsig module and an -+x509 certificate for verification. Building the appendedsig module into the -+core grub image is recommended. ++where @code{\n} represents the line-feed character, @code{0x0a}. + +Certificates can be managed at boot time using the @pxref{trust_certificate}, +@pxref{distrust_certificate} and @pxref{list_certificates} commands. @@ -289,32 +289,32 @@ index 7fc2a62a4f8..7fe365414e4 100644 +@end example + +Enforcement of signature verification is controlled by the -+@code{check_appended_signatures} variable. Verification will only take place -+when files are loaded if the variable is set to @code{enforce}. If a -+certificate is built into the grub core image with the @code{--x509} parameter, -+the variable will be automatically set to @code{enforce} when the appendedsig -+module is loaded. ++@code{check_appended_signatures} variable. ++ ++@itemize ++@item @samp{no}: no verification is performed. This is the default when GRUB ++ is not in @pxref{Lockdown} mode. ++@item @samp{enforce}: verification is performed. Verification can be disabled ++ by setting the variable back to @samp{no}. ++@item @samp{forced}: verification is performed and cannot be disabled. This is ++ set when GRUB is in Lockdown when the appendedsig module is loaded. ++@end itemize + +Unlike GPG-style signatures, not all files loaded by GRUB are required to be -+signed. Once verification is turned on, the following file types must carry -+appended signatures: ++signed. Once verification is turned on, the following file types will have ++appended signatures verified: + -+@enumerate -+@item Linux, Multiboot, BSD, XNU and Plan9 kernels -+@item Grub modules, except those built in to the core image ++@itemize ++@item Linux kernels ++@item GRUB modules, except those built into the core image +@item Any new certificate files to be trusted -+@end enumerate ++@end itemize + +ACPI tables and Device Tree images will not be checked for appended signatures +but must be verified by another mechanism such as GPG-style signatures before +they will be loaded. + -+No attempt is made to validate any other file type. In particular, -+chain-loaded binaries are not verified - if your platform supports -+chain-loading and this cannot be disabled, consider an alternative secure -+boot mechanism. -+ -+As with GPG-style appended signatures, signature checking does @strong{not} ++Unless lockdown mode is enabled, signature checking does @strong{not} +stop an attacker with console access from dropping manually to the GRUB +console and executing: + @@ -325,9 +325,17 @@ index 7fc2a62a4f8..7fe365414e4 100644 +Refer to the section on password-protecting GRUB (@pxref{Authentication +and authorisation}) for more information on preventing this. + -+Additionally, special care must be taken around the @command{loadenv} command, -+which can be used to turn off @code{check_appended_signature}. ++Additionally, unless lockdown mode is enabled: + - @node Signing GRUB itself - @section Signing GRUB itself ++@itemize ++@item Special care must be taken around the @command{loadenv} command, which ++ can be used to turn off @code{check_appended_signature}. ++ ++@item If the grub configuration file is loaded from the disk, anyone who can ++ modify the file on disk can turn off @code{check_appended_signature}. ++ Consider embedding the configuration into the core grub image. ++@end itemize ++ + @node UEFI secure boot and shim + @section UEFI secure boot and shim support diff --git a/0194-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch b/0194-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch new file mode 100644 index 0000000..cce1d07 --- /dev/null +++ b/0194-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch @@ -0,0 +1,109 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Daniel Axtens +Date: Mon, 28 Sep 2020 11:11:17 +1000 +Subject: [PATCH] ieee1275: enter lockdown based on /ibm,secure-boot + +If the 'ibm,secure-boot' property of the root node is 2 or greater, +enter lockdown. + +Signed-off-by: Daniel Axtens +--- + grub-core/Makefile.core.def | 1 + + grub-core/kern/ieee1275/init.c | 27 +++++++++++++++++++++++++++ + include/grub/lockdown.h | 3 ++- + docs/grub.texi | 4 ++-- + 4 files changed, 32 insertions(+), 3 deletions(-) + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index 6bddc841b85..3f3459b2c70 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -323,6 +323,7 @@ kernel = { + powerpc_ieee1275 = kern/powerpc/cache.S; + powerpc_ieee1275 = kern/powerpc/dl.c; + powerpc_ieee1275 = kern/powerpc/compiler-rt.S; ++ powerpc_ieee1275 = kern/lockdown.c; + + sparc64_ieee1275 = kern/sparc64/cache.S; + sparc64_ieee1275 = kern/sparc64/dl.c; +diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c +index 937c1bc44cb..fc7d9712729 100644 +--- a/grub-core/kern/ieee1275/init.c ++++ b/grub-core/kern/ieee1275/init.c +@@ -44,6 +44,7 @@ + #ifdef __sparc__ + #include + #endif ++#include + + /* The minimal heap size we can live with. */ + #define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024) +@@ -271,6 +272,30 @@ grub_parse_cmdline (void) + } + } + ++static void ++grub_get_ieee1275_secure_boot (void) ++{ ++ grub_ieee1275_phandle_t root; ++ int rc; ++ grub_uint32_t is_sb; ++ ++ grub_ieee1275_finddevice ("/", &root); ++ ++ rc = grub_ieee1275_get_integer_property (root, "ibm,secure-boot", &is_sb, ++ sizeof (is_sb), 0); ++ ++ /* ibm,secure-boot: ++ * 0 - disabled ++ * 1 - audit ++ * 2 - enforce ++ * 3 - enforce + OS-specific behaviour ++ * ++ * We only support enforce. ++ */ ++ if (rc >= 0 && is_sb >= 2) ++ grub_lockdown (); ++} ++ + grub_addr_t grub_modbase; + + void +@@ -296,6 +321,8 @@ grub_machine_init (void) + #else + grub_install_get_time_ms (grub_rtc_get_time_ms); + #endif ++ ++ grub_get_ieee1275_secure_boot (); + } + + void +diff --git a/include/grub/lockdown.h b/include/grub/lockdown.h +index 40531fa823b..ebfee4bf06e 100644 +--- a/include/grub/lockdown.h ++++ b/include/grub/lockdown.h +@@ -24,7 +24,8 @@ + #define GRUB_LOCKDOWN_DISABLED 0 + #define GRUB_LOCKDOWN_ENABLED 1 + +-#ifdef GRUB_MACHINE_EFI ++#if defined(GRUB_MACHINE_EFI) || \ ++ (defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275)) + extern void + EXPORT_FUNC (grub_lockdown) (void); + extern int +diff --git a/docs/grub.texi b/docs/grub.texi +index 7b5d7800418..cb5804fd6fe 100644 +--- a/docs/grub.texi ++++ b/docs/grub.texi +@@ -6224,8 +6224,8 @@ Measured boot is currently only supported on EFI platforms. + @section Lockdown when booting on a secure setup + + The GRUB can be locked down when booted on a secure boot environment, for example +-if the UEFI secure boot is enabled. On a locked down configuration, the GRUB will +-be restricted and some operations/commands cannot be executed. ++if UEFI or Power secure boot is enabled. On a locked down configuration, the ++GRUB will be restricted and some operations/commands cannot be executed. + + The @samp{lockdown} variable is set to @samp{y} when the GRUB is locked down. + Otherwise it does not exit. diff --git a/0195-RISC-V-Add-__clzdi2-symbol.patch b/0195-RISC-V-Add-__clzdi2-symbol.patch deleted file mode 100644 index 492aaef..0000000 --- a/0195-RISC-V-Add-__clzdi2-symbol.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Andreas Schwab -Date: Thu, 19 Sep 2019 09:39:04 +0200 -Subject: [PATCH] RISC-V: Add __clzdi2 symbol - -This is needed for the zstd module build for riscv64-emu. - -Signed-off-by: Andreas Schwab -Reviewed-by: Daniel Kiper ---- - configure.ac | 2 +- - include/grub/compiler-rt-emu.h | 5 +++++ - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 5076d635c57..eff160b6931 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1444,7 +1444,7 @@ fi - - # Check for libgcc symbols - if test x"$platform" = xemu; then --AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) -+AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __clzdi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) - fi - - if test "x$TARGET_APPLE_LINKER" = x1 ; then -diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h -index b21425d9eb8..fde620ac186 100644 ---- a/include/grub/compiler-rt-emu.h -+++ b/include/grub/compiler-rt-emu.h -@@ -74,6 +74,11 @@ unsigned - EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); - #endif - -+#ifdef HAVE___CLZDI2 -+int -+EXPORT_FUNC (__clzdi2) (grub_uint64_t x); -+#endif -+ - #ifdef HAVE___AEABI_UIDIV - grub_uint32_t - EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); diff --git a/0195-Revert-templates-Properly-disable-the-os-prober-by-d.patch b/0195-Revert-templates-Properly-disable-the-os-prober-by-d.patch new file mode 100644 index 0000000..6c2b8a4 --- /dev/null +++ b/0195-Revert-templates-Properly-disable-the-os-prober-by-d.patch @@ -0,0 +1,71 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Fri, 12 Mar 2021 23:25:01 +0100 +Subject: [PATCH] Revert "templates: Properly disable the os-prober by default" + +This reverts commit 54e0a1bbf1e9106901a557195bb35e5e20fb3925. +--- + util/grub-mkconfig.in | 5 +---- + util/grub.d/30_os-prober.in | 8 ++++---- + 2 files changed, 5 insertions(+), 8 deletions(-) + +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index 1a70b7ea056..f55339a3f64 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -147,9 +147,6 @@ GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2 + GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" + GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true + +-# Disable os-prober by default due to security reasons. +-GRUB_DISABLE_OS_PROBER="true" +- + # Filesystem for the device containing our userland. Used for stuff like + # choosing Hurd filesystem module. + GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`" +@@ -213,7 +210,6 @@ export GRUB_DEVICE \ + GRUB_DEVICE_PARTUUID \ + GRUB_DEVICE_BOOT \ + GRUB_DEVICE_BOOT_UUID \ +- GRUB_DISABLE_OS_PROBER \ + GRUB_FS \ + GRUB_FONT \ + GRUB_PRELOAD_MODULES \ +@@ -255,6 +251,7 @@ export GRUB_DEFAULT \ + GRUB_BACKGROUND \ + GRUB_THEME \ + GRUB_GFXPAYLOAD_LINUX \ ++ GRUB_DISABLE_OS_PROBER \ + GRUB_INIT_TUNE \ + GRUB_SAVEDEFAULT \ + GRUB_ENABLE_CRYPTODISK \ +diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in +index 21bbace4647..7591edc58ed 100644 +--- a/util/grub.d/30_os-prober.in ++++ b/util/grub.d/30_os-prober.in +@@ -26,8 +26,8 @@ export TEXTDOMAINDIR="@localedir@" + + . "$pkgdatadir/grub-mkconfig_lib" + +-if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then +- grub_warn "$(gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.")" ++if [ "x${GRUB_DISABLE_OS_PROBER}" = "xfalse" ]; then ++ gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.\n" + exit 0 + fi + +@@ -36,12 +36,12 @@ if ! command -v os-prober > /dev/null || ! command -v linux-boot-prober > /dev/n + exit 0 + fi + +-grub_warn "$(gettext_printf "os-prober will be executed to detect other bootable partitions.\nIt's output will be used to detect bootable binaries on them and create new boot entries.")" +- + OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`" + if [ -z "${OSPROBED}" ] ; then + # empty os-prober output, nothing doing + exit 0 ++else ++ grub_warn "$(gettext_printf "os-prober was executed to detect other bootable partitions.\nIt's output will be used to detect bootable binaries on them and create new boot entries.")" + fi + + osx_entry() { diff --git a/0196-Revert-templates-Disable-the-os-prober-by-default.patch b/0196-Revert-templates-Disable-the-os-prober-by-default.patch new file mode 100644 index 0000000..b97c4c7 --- /dev/null +++ b/0196-Revert-templates-Disable-the-os-prober-by-default.patch @@ -0,0 +1,70 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Fri, 12 Mar 2021 23:26:15 +0100 +Subject: [PATCH] Revert "templates: Disable the os-prober by default" + +This reverts commit e346414725a70e5c74ee87ca14e580c66f517666. +--- + docs/grub.texi | 18 ++++++++---------- + util/grub.d/30_os-prober.in | 5 +---- + 2 files changed, 9 insertions(+), 14 deletions(-) + +diff --git a/docs/grub.texi b/docs/grub.texi +index cb5804fd6fe..d183575bc18 100644 +--- a/docs/grub.texi ++++ b/docs/grub.texi +@@ -1526,13 +1526,10 @@ boot sequence. If you have problems, set this option to @samp{text} and + GRUB will tell Linux to boot in normal text mode. + + @item GRUB_DISABLE_OS_PROBER +-The @command{grub2-mkconfig} has a feature to use the external +-@command{os-prober} program to discover other operating systems installed on +-the same machine and generate appropriate menu entries for them. It is disabled +-by default since automatic and silent execution of @command{os-prober}, and +-creating boot entries based on that data, is a potential attack vector. Set +-this option to @samp{false} to enable this feature in the +-@command{grub2-mkconfig} command. ++Normally, @command{grub2-mkconfig} will try to use the external ++@command{os-prober} program, if installed, to discover other operating ++systems installed on the same system and generate appropriate menu entries ++for them. Set this option to @samp{true} to disable this. + + @item GRUB_OS_PROBER_SKIP_LIST + List of space-separated FS UUIDs of filesystems to be ignored from os-prober +@@ -1860,9 +1857,10 @@ than zero; otherwise 0. + @section Multi-boot manual config + + Currently autogenerating config files for multi-boot environments depends on +-os-prober and has several shortcomings. Due to that it is disabled by default. +-It is advised to use the power of GRUB syntax and do it yourself. A possible +-configuration is detailed here, feel free to adjust to your needs. ++os-prober and has several shortcomings. While fixing it is scheduled for the ++next release, meanwhile you can make use of the power of GRUB syntax and do it ++yourself. A possible configuration is detailed here, feel free to adjust to your ++needs. + + First create a separate GRUB partition, big enough to hold GRUB. Some of the + following entries show how to load OS installer images from this same partition, +diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in +index 7591edc58ed..3c9431cfcfb 100644 +--- a/util/grub.d/30_os-prober.in ++++ b/util/grub.d/30_os-prober.in +@@ -26,8 +26,7 @@ export TEXTDOMAINDIR="@localedir@" + + . "$pkgdatadir/grub-mkconfig_lib" + +-if [ "x${GRUB_DISABLE_OS_PROBER}" = "xfalse" ]; then +- gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.\n" ++if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then + exit 0 + fi + +@@ -40,8 +39,6 @@ OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`" + if [ -z "${OSPROBED}" ] ; then + # empty os-prober output, nothing doing + exit 0 +-else +- grub_warn "$(gettext_printf "os-prober was executed to detect other bootable partitions.\nIt's output will be used to detect bootable binaries on them and create new boot entries.")" + fi + + osx_entry() { diff --git a/0196-grub-install-Define-default-platform-for-RISC-V.patch b/0196-grub-install-Define-default-platform-for-RISC-V.patch deleted file mode 100644 index 962c080..0000000 --- a/0196-grub-install-Define-default-platform-for-RISC-V.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Andreas Schwab -Date: Thu, 15 Aug 2019 16:55:13 +0200 -Subject: [PATCH] grub-install: Define default platform for RISC-V - -Signed-off-by: Andreas Schwab -Reviewed-by: Daniel Kiper -Reviewed-by: Alexander Graf ---- - util/grub-install.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/util/grub-install.c b/util/grub-install.c -index 37fcdac12cc..8b6a037903e 100644 ---- a/util/grub-install.c -+++ b/util/grub-install.c -@@ -324,6 +324,14 @@ get_default_platform (void) - return "arm64-efi"; - #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__) - return grub_install_get_default_x86_platform (); -+#elif defined (__riscv) -+#if __riscv_xlen == 32 -+ return "riscv32-efi"; -+#elif __riscv_xlen == 64 -+ return "riscv64-efi"; -+#else -+ return NULL; -+#endif - #else - return NULL; - #endif diff --git a/0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch b/0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch deleted file mode 100644 index 55efdaa..0000000 --- a/0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 14 Jan 2020 17:41:29 +0100 -Subject: [PATCH] blscfg: Always use the root variable to search for BLS - snippets - -The boot and root variables are set by grub2-mkconfig to tell GRUB what -are the devices and partitions used as the EFI System Partition (ESP) -and to store the /boot directory (or used as the /boot mount point). - -But the boot variable is not needed anymore, this was added because the -blscfg module used to search for the BLS snippets in the ESP, but was -later changed to always search for the BLS files in /boot even for EFI. - -When doing that change, the logic was made backwards and so the boot -variable is wrongly used for legacy BIOS. This only works because this -is set to the same value as the root variable. - -So the correct thing to do is to always use the root variable to search -the BLS snippets, since that is set to the partition that stores them. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 069db721bec..24e35a40f24 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -1018,14 +1018,12 @@ bls_load_entries (const char *path) - if (!devid) { - #ifdef GRUB_MACHINE_EMU - devid = "host"; --#elif defined(GRUB_MACHINE_EFI) -+#else - devid = grub_env_get ("root"); --#else -- devid = grub_env_get ("boot"); - #endif - if (!devid) - return grub_error (GRUB_ERR_FILE_NOT_FOUND, -- N_("variable `%s' isn't set"), "boot"); -+ N_("variable `%s' isn't set"), "root"); - } - - grub_dprintf ("blscfg", "opening %s\n", devid); diff --git a/0204-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch b/0204-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch deleted file mode 100644 index fa35f65..0000000 --- a/0204-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 16 Mar 2020 13:51:45 +0100 -Subject: [PATCH] blscfg: return NULL instead of a zero-length array in - bls_make_list() - -The bls_make_list() function returns a list of all the values for a given -key and if there is none a NULL pointer should be returned. But currently -is returnin a zero-length array instead. - -This makes the callers to wrongly assume that there are values for a key -and populate wrong menu entries. For example menu entries are populated -with an initrd command even if there is no initrd fiel in the BLS file. - -Resolves: rhbz#1806022 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 24e35a40f24..9263a5c1a02 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -600,6 +600,12 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) - list[nlist] = NULL; - } - -+ if (!nlist) -+ { -+ grub_free (list); -+ return NULL; -+ } -+ - if (num) - *num = nlist; - diff --git a/0205-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch b/0205-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch deleted file mode 100644 index 5993a6b..0000000 --- a/0205-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 26 Mar 2020 15:08:30 +0100 -Subject: [PATCH] grub-switch-to-blscfg: Update grub2 binary in ESP for OSTree - systems - -The grub2 EFI binary in the ESP isn't updated as a part of an OSTree update -transaction. So let's make the script to update this and also create a file -to indicate that the installed version has support for the blscfg module. - -Related: rhbz#1751272 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 49b3985fadb..a05a8d98554 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -266,6 +266,15 @@ copy_bls() { - fi - } - -+# The grub2 EFI binary is not copied to the ESP as a part of an ostree -+# transaction. Make sure a grub2 version with BLS support is installed. -+if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars/; then -+ grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" -+ cp ${grub_binary} ${grubdir} || exit 1 -+ # Create a hidden file to indicate that grub2 now has BLS support. -+ touch /boot/grub2/.grub2-blscfg-supported -+fi -+ - GENERATE=0 - if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \ - | grep -vq '^GRUB_ENABLE_BLSCFG="*true"*\s*$' ; then diff --git a/0206-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch b/0206-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch deleted file mode 100644 index 27ef6e0..0000000 --- a/0206-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 2 Apr 2020 11:07:24 +0200 -Subject: [PATCH] grub-switch-to-blscfg: Only mark GRUB as BLS supported if - blsdir isn't set - -If the user set the blsdir environemnt variable to a path that is not the -default where ostree writes the BLS snippets, the blscfg module won't be -able to parse them and can lead to not having any menu entries on boot. - -So to minimize the risk of things going wrong when dropping the 15_ostree -script used by ostree to create the menu entries, only mark the bootloader -as BLS supported if the blsdir variable has not been set. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index a05a8d98554..4bbed8e4fe9 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -267,8 +267,11 @@ copy_bls() { - } - - # The grub2 EFI binary is not copied to the ESP as a part of an ostree --# transaction. Make sure a grub2 version with BLS support is installed. --if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars/; then -+# transaction. Make sure a grub2 version with BLS support is installed -+# but only do this if the blsdir is not set, to make sure that the BLS -+# parsing module will search for the BLS snippets in the default path. -+if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \ -+ ! ${grub_editenv} - list | grep -q blsdir; then - grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" - cp ${grub_binary} ${grubdir} || exit 1 - # Create a hidden file to indicate that grub2 now has BLS support. diff --git a/0207-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch b/0207-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch deleted file mode 100644 index cd4be69..0000000 --- a/0207-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch +++ /dev/null @@ -1,662 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 31 Mar 2020 12:35:42 +0200 -Subject: [PATCH] 10_linux.in: Merge logic from 10_linux_bls and drop that - script - -There's a 10_linux_bls snippet that's used in ppc64le machines to generate -a set of menuentry commands by parsing BLS configs in /boot/loader/entries. - -This was made because on PowerNV ppc64le machines that boot using the OPAL -firmware, there could be an old version of the Petitboot bootloader that -doesn't have support to parse BLS snippets. - -But there is no need to have a separate GRUB script for that and the logic -could just be part of the usual 10_linux snippet. - -Also the BLS files could be used directly if the bootloader has support to -parse them, which is the case for GRUB that's used in ppc64le OF or if the -Petitboot used in ppc64le OPAL machines is version 1.8.0 or newer. - -So only generate the menuentry commands from the BLS snippets in the case -of OPAL machines with an old Petitboot version. - -Signed-off-by: Javier Martinez Canillas ---- - Makefile.util.def | 7 - - util/grub.d/10_linux.in | 97 ++++++++- - util/grub.d/10_linux_bls.in | 470 -------------------------------------------- - 3 files changed, 96 insertions(+), 478 deletions(-) - delete mode 100644 util/grub.d/10_linux_bls.in - -diff --git a/Makefile.util.def b/Makefile.util.def -index 1fa92caad4d..f3a699691bf 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -517,13 +517,6 @@ script = { - condition = COND_HOST_LINUX; - }; - --script = { -- name = '10_linux_bls'; -- common = util/grub.d/10_linux_bls.in; -- installdir = grubconf; -- condition = COND_HOST_LINUX; --}; -- - script = { - name = '10_reset_boot_success'; - common = util/grub.d/10_reset_boot_success.in; -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index b70dca27567..c72cc3246bb 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -84,18 +84,86 @@ esac - - populate_header_warn() - { -+if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then -+ bls_parser="10_linux script" -+else -+ bls_parser="blscfg command" -+fi - cat <&2 -+ -+ files=($(for bls in ${blsdir}/*.conf ; do -+ if ! [[ -e "${bls}" ]] ; then -+ continue -+ fi -+ bls="${bls%.conf}" -+ bls="${bls##*/}" -+ echo "${bls}" -+ done | ${kernel_sort} | tac)) || : -+ -+ for bls in "${files[@]}" ; do -+ read_config "${blsdir}/${bls}.conf" -+ -+ menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" -+ menu="${menu}\t linux ${linux} ${options}\n" -+ if [ -n "${initrd}" ] ; then -+ menu="${menu}\t initrd ${boot_prefix}${initrd}\n" -+ fi -+ menu="${menu}}\n\n" -+ done -+ # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation -+ printf "$menu" -+} -+ - if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - if [ x$dirname = x/ ]; then - if [ -z "${prepare_root_cache}" ]; then -@@ -115,6 +183,26 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - prepare_grub_to_access_device_with_variable boot ${boot_device} - fi - -+ arch="$(uname -m)" -+ if [ "x${arch}" = "xppc64le" ] && [ -d /sys/firmware/opal ]; then -+ -+ petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" -+ -+ if test -e ${petitboot_path}; then -+ read -a petitboot_version < ${petitboot_path} -+ petitboot_version="$(echo ${petitboot_version//v})" -+ major_version="$(echo ${petitboot_version} | cut -d . -f1)" -+ minor_version="$(echo ${petitboot_version} | cut -d . -f2)" -+ -+ if test -z ${petitboot_version} || test ${major_version} -lt 1 || \ -+ test ${major_version} -eq 1 -a ${minor_version} -lt 8; then -+ BLS_POPULATE_MENU="true" -+ fi -+ else -+ BLS_POPULATE_MENU="true" -+ fi -+ fi -+ - populate_header_warn - - cat << EOF -@@ -129,10 +217,17 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - if [ -z "\${kernelopts}" ]; then - set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - fi -+EOF -+ -+ if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then -+ populate_menu -+ else -+ cat << EOF - - insmod blscfg - blscfg - EOF -+ fi - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then - blsdir="/boot/loader/entries" -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -deleted file mode 100644 -index 68fbedf2129..00000000000 ---- a/util/grub.d/10_linux_bls.in -+++ /dev/null -@@ -1,470 +0,0 @@ --#! /bin/sh --set -e -- --# grub-mkconfig helper script. --# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. --# --# GRUB is free software: you can redistribute it and/or modify --# it under the terms of the GNU General Public License as published by --# the Free Software Foundation, either version 3 of the License, or --# (at your option) any later version. --# --# GRUB is distributed in the hope that it will be useful, --# but WITHOUT ANY WARRANTY; without even the implied warranty of --# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --# GNU General Public License for more details. --# --# You should have received a copy of the GNU General Public License --# along with GRUB. If not, see . -- --prefix="@prefix@" --exec_prefix="@exec_prefix@" --datarootdir="@datarootdir@" -- --. "$pkgdatadir/grub-mkconfig_lib" -- --export TEXTDOMAIN=@PACKAGE@ --export TEXTDOMAINDIR="@localedir@" -- --CLASS="--class gnu-linux --class gnu --class os --unrestricted" -- --if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then -- OS="$(eval $(grep PRETTY_NAME /etc/os-release) ; echo ${PRETTY_NAME})" -- CLASS="--class $(eval $(grep '^ID_LIKE=\|^ID=' /etc/os-release) ; [ -n "${ID_LIKE}" ] && echo ${ID_LIKE} || echo ${ID}) ${CLASS}" --else -- OS="${GRUB_DISTRIBUTOR}" -- CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" --fi -- --# loop-AES arranges things so that /dev/loop/X can be our root device, but --# the initrds that Linux uses don't like that. --case ${GRUB_DEVICE} in -- /dev/loop/*|/dev/loop[0-9]) -- GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` -- ;; --esac -- --# Default to disabling partition uuid support to maintian compatibility with --# older kernels. --GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} -- --# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter --# and mounting btrfs requires user space scanning, so force UUID in this case. --if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ -- || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ -- && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ -- || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ -- && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ -- || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then -- LINUX_ROOT_DEVICE=${GRUB_DEVICE} --elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ -- || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then -- LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} --else -- LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} --fi -- --case x"$GRUB_FS" in -- xbtrfs) -- if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then -- GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}" -- else -- rootsubvol="`make_system_path_relative_to_its_root /`" -- rootsubvol="${rootsubvol#/}" -- if [ "x${rootsubvol}" != x ]; then -- GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" -- fi -- fi;; -- xzfs) -- rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` -- bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" -- LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" -- ;; --esac -- --mktitle () --{ -- local title_type -- local version -- local OS_NAME -- local OS_VERS -- -- title_type=$1 && shift -- version=$1 && shift -- -- OS_NAME="$(eval $(grep ^NAME= /etc/os-release) ; echo ${NAME})" -- OS_VERS="$(eval $(grep ^VERSION= /etc/os-release) ; echo ${VERSION})" -- -- case $title_type in -- recovery) -- title=$(printf '%s (%s) %s (recovery mode)' \ -- "${OS_NAME}" "${version}" "${OS_VERS}") -- ;; -- *) -- title=$(printf '%s (%s) %s' \ -- "${OS_NAME}" "${version}" "${OS_VERS}") -- ;; -- esac -- echo -n ${title} --} -- --title_correction_code= -- --populate_header_warn() --{ --cat <&2 -- -- files=($(for bls in ${blsdir}/*.conf ; do -- if ! [[ -e "${bls}" ]] ; then -- continue -- fi -- bls="${bls%.conf}" -- bls="${bls##*/}" -- echo "${bls}" -- done | ${kernel_sort} | tac)) || : -- -- for bls in "${files[@]}" ; do -- read_config "${blsdir}/${bls}.conf" -- -- menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" -- menu="${menu}\t linux ${linux} ${options}\n" -- if [ -n "${initrd}" ] ; then -- menu="${menu}\t initrd ${boot_prefix}${initrd}\n" -- fi -- menu="${menu}}\n\n" -- done -- # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation -- printf "$menu" --} -- --linux_entry () --{ -- os="$1" -- version="$2" -- type="$3" -- isdebug="$4" -- args="$5" -- -- if [ -z "$boot_device_id" ]; then -- boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -- fi -- -- if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -- if [ x$dirname = x/ ]; then -- if [ -z "${prepare_root_cache}" ]; then -- prepare_grub_to_access_device ${GRUB_DEVICE} -- fi -- else -- if [ -z "${prepare_boot_cache}" ]; then -- prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} -- fi -- fi -- -- if [ -d /sys/firmware/efi ]; then -- bootefi_device="`${grub_probe} --target=device /boot/efi/`" -- prepare_grub_to_access_device_with_variable boot ${bootefi_device} -- else -- boot_device="`${grub_probe} --target=device /boot/`" -- prepare_grub_to_access_device_with_variable boot ${boot_device} -- fi -- -- populate_header_warn -- populate_menu -- -- if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then -- blsdir="/boot/loader/entries" -- [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})" -- if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then -- blsdir=$(make_system_path_relative_to_its_root "${blsdir}") -- if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then -- ${grub_editenv} - set blsdir="${blsdir}" -- fi -- fi -- -- ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" -- if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then -- ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" -- fi -- fi -- -- exit 0 -- fi -- -- if [ x$type != xsimple ] ; then -- title=$(mktitle "$type" "$version") -- if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then -- replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" -- quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" -- title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" -- fi -- if [ x$isdebug = xdebug ]; then -- title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}" -- fi -- echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -- else -- echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" -- fi -- if [ x$type != xrecovery ] ; then -- save_default_entry | grub_add_tab -- fi -- -- # Use ELILO's generic "efifb" when it's known to be available. -- # FIXME: We need an interface to select vesafb in case efifb can't be used. -- if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then -- echo " load_video" | sed "s/^/$submenu_indentation/" -- if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \ -- && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then -- echo " set gfxpayload=keep" | sed "s/^/$submenu_indentation/" -- fi -- else -- if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then -- echo " load_video" | sed "s/^/$submenu_indentation/" -- fi -- echo " set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/" -- fi -- -- echo " insmod gzio" | sed "s/^/$submenu_indentation/" -- -- if [ x$dirname = x/ ]; then -- if [ -z "${prepare_root_cache}" ]; then -- prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)" -- fi -- printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/" -- else -- if [ -z "${prepare_boot_cache}" ]; then -- prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)" -- fi -- printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" -- fi -- sed "s/^/$submenu_indentation/" << EOF -- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} --EOF -- if test -n "${initrd}" ; then -- initrd_path= -- for i in ${initrd}; do -- initrd_path="${initrd_path} ${rel_dirname}/${i}" -- done -- sed "s/^/$submenu_indentation/" << EOF -- initrd $(echo $initrd_path) --EOF -- fi -- if test -n "${fdt}" ; then -- sed "s/^/$submenu_indentation/" << EOF -- devicetree ${rel_dirname}/${fdt} --EOF -- fi -- sed "s/^/$submenu_indentation/" << EOF --} --EOF --} -- --machine=`uname -m` --case "x$machine" in -- xi?86 | xx86_64) -- list= -- for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do -- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -- done ;; -- *) -- list= -- for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do -- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -- done ;; --esac -- --if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -- for i in /boot/ostree/*/vmlinuz-* ; do -- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -- done --fi -- --case "$machine" in -- i?86) GENKERNEL_ARCH="x86" ;; -- mips|mips64) GENKERNEL_ARCH="mips" ;; -- mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;; -- arm*) GENKERNEL_ARCH="arm" ;; -- *) GENKERNEL_ARCH="$machine" ;; --esac -- --prepare_boot_cache= --prepare_root_cache= --boot_device_id= --title_correction_code= -- --# Extra indentation to add to menu entries in a submenu. We're not in a submenu --# yet, so it's empty. In a submenu it will be equal to '\t' (one tab). --submenu_indentation="" -- --is_top_level=true --while [ "x$list" != "x" ] ; do -- linux=`version_find_latest $list` -- if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -- gettext_printf "Found linux image: %s\n" "$linux" >&2 -- fi -- -- basename=`basename $linux` -- dirname=`dirname $linux` -- rel_dirname=`make_system_path_relative_to_its_root $dirname` -- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` -- alt_version=`echo $version | sed -e "s,\.old$,,g"` -- linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" -- -- initrd_early= -- for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \ -- ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do -- if test -e "${dirname}/${i}" ; then -- initrd_early="${initrd_early} ${i}" -- fi -- done -- -- initrd_real= -- for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \ -- "initrd-${version}" "initramfs-${version}.img" \ -- "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ -- "initrd-${alt_version}" "initramfs-${alt_version}.img" \ -- "initramfs-genkernel-${version}" \ -- "initramfs-genkernel-${alt_version}" \ -- "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \ -- "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do -- if test -e "${dirname}/${i}" ; then -- initrd_real="${i}" -- break -- fi -- done -- -- initrd= -- if test -n "${initrd_early}" || test -n "${initrd_real}"; then -- initrd="${initrd_early} ${initrd_real}" -- -- initrd_display= -- for i in ${initrd}; do -- initrd_display="${initrd_display} ${dirname}/${i}" -- done -- if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 -- fi -- fi -- -- fdt= -- for i in "dtb-${version}" "dtb-${alt_version}"; do -- if test -f "${dirname}/${i}/${GRUB_DEFAULT_DTB}" ; then -- fdt="${i}/${GRUB_DEFAULT_DTB}" -- break -- fi -- done -- -- config= -- for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do -- if test -e "${i}" ; then -- config="${i}" -- break -- fi -- done -- -- initramfs= -- if test -n "${config}" ; then -- initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` -- fi -- -- if test -z "${initramfs}" && test -z "${initrd_real}" ; then -- # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's -- # no initrd or builtin initramfs, it can't work here. -- if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ -- || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then -- -- linux_root_device_thisversion=${GRUB_DEVICE} -- else -- linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} -- fi -- fi -- -- if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then -- GRUB_DISABLE_SUBMENU="true" -- fi -- -- if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then -- linux_entry "${OS}" "${version}" simple standard \ -- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -- if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -- linux_entry "${OS}" "${version}" simple debug \ -- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" -- fi -- -- submenu_indentation="$grub_tab" -- -- if [ -z "$boot_device_id" ]; then -- boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -- fi -- # TRANSLATORS: %s is replaced with an OS name -- echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {" -- is_top_level=false -- fi -- -- linux_entry "${OS}" "${version}" advanced standard \ -- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -- if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -- linux_entry "${OS}" "${version}" advanced debug \ -- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" -- fi -- -- if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then -- linux_entry "${OS}" "${version}" recovery standard \ -- "single ${GRUB_CMDLINE_LINUX}" -- fi -- -- list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` --done -- --# If at least one kernel was found, then we need to --# add a closing '}' for the submenu command. --if [ x"$is_top_level" != xtrue ]; then -- echo '}' --fi -- --echo "$title_correction_code" diff --git a/0208-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch b/0208-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch deleted file mode 100644 index c131a7f..0000000 --- a/0208-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 16 Apr 2020 18:53:03 +0200 -Subject: [PATCH] grub-switch-to-blscfg: Use install to copy GRUB binary, - modules and config - -By default the cp command truncates the destination before copying from the -source, so if interrupted it can lead to a file that's half written. - -This behavior can be modified using the --remove-destination option, but is -usually a better choice to use the install tool for this. So let's do that. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 4bbed8e4fe9..3333a620c28 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -273,7 +273,7 @@ copy_bls() { - if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \ - ! ${grub_editenv} - list | grep -q blsdir; then - grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" -- cp ${grub_binary} ${grubdir} || exit 1 -+ install -m 700 ${grub_binary} ${grubdir} || exit 1 - # Create a hidden file to indicate that grub2 now has BLS support. - touch /boot/grub2/.grub2-blscfg-supported - fi -@@ -307,13 +307,13 @@ if [ "${GENERATE}" -eq 1 ] ; then - - if [ -n "${mod_dir}" ]; then - for mod in blscfg increment; do -- cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 -+ install -m 700 ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 - done - fi - - cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" - if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then -- cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" -+ install -m 700 "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" - sed -i"${backupsuffix}" \ - -e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \ - "${etcdefaultgrub}" diff --git a/0209-10_linux.in-Enable-BLS-configuration-if-new-kernel-p.patch b/0209-10_linux.in-Enable-BLS-configuration-if-new-kernel-p.patch deleted file mode 100644 index 99c26dd..0000000 --- a/0209-10_linux.in-Enable-BLS-configuration-if-new-kernel-p.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 16 Apr 2020 18:53:05 +0200 -Subject: [PATCH] 10_linux.in: Enable BLS configuration if new-kernel-pkg isn't - present - -Currently if the the GRUB_ENABLE_BLSCFG option in /etc/default/grub hasn't -been set, the 10_linux script will generate a GRUB configuration that does -not include the blscfg command to populate the menu entries from BLS files. - -But on kernel install the /usr/lib/kernel/install.d/20-grub.install script -will only add menuentry commands to the GRUB config file if the old grubby -tool and new-kernel-pkg script are installed. - -So a configuration with the GRUB_ENABLE_BLSCFG option will lead to a setup -where new kernel entries are not added. Make a BLS config the default if -that option wasn't set and the new-kernel-pkg script is not present. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index c72cc3246bb..847646bd8a8 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -164,6 +164,11 @@ populate_menu() - printf "$menu" - } - -+# Make BLS the default if GRUB_ENABLE_BLSCFG was not set and grubby is not installed. -+if [ -z "${GRUB_ENABLE_BLSCFG}" ] && [ -z "$(which new-kernel-pkg 2> /dev/null)" ]; then -+ GRUB_ENABLE_BLSCFG="true" -+fi -+ - if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - if [ x$dirname = x/ ]; then - if [ -z "${prepare_root_cache}" ]; then diff --git a/0211-blscfg-Lookup-default_kernelopts-variable-as-fallbac.patch b/0211-blscfg-Lookup-default_kernelopts-variable-as-fallbac.patch deleted file mode 100644 index 483efc4..0000000 --- a/0211-blscfg-Lookup-default_kernelopts-variable-as-fallbac.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 29 Apr 2020 20:08:27 +0200 -Subject: [PATCH] blscfg: Lookup default_kernelopts variable as fallback for - options - -The 10_linux script sets a variable that contains the kernel command line -parameters. This is done so the entries will still have a kernel cmdline -defined even if the grubenv can't be read. - -But older versions of the script used to set a default_kernelopts variable -while newer versions just sets the kernelopts, which is what's defined in -the BLS snippets. - -The blscfg module needs to keep looking for the default_kernelops since it -may be that a user doesn't have a grubenv file and has an older grub.cfg -that sets this variable instead of kernelopts. - -Related: rhbz#1765297 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 9263a5c1a02..4ec6504d9a4 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -759,6 +759,10 @@ static void create_entry (struct bls_entry *entry) - - title = bls_get_val (entry, "title", NULL); - options = expand_val (bls_get_val (entry, "options", NULL)); -+ -+ if (!options) -+ options = expand_val (grub_env_get("default_kernelopts")); -+ - initrds = bls_make_list (entry, "initrd", NULL); - - devicetree = expand_val (bls_get_val (entry, "devicetree", NULL)); diff --git a/0212-10_linux.in-fix-early-exit-due-error-when-reading-pe.patch b/0212-10_linux.in-fix-early-exit-due-error-when-reading-pe.patch deleted file mode 100644 index 75eb75a..0000000 --- a/0212-10_linux.in-fix-early-exit-due-error-when-reading-pe.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 30 Apr 2020 15:45:31 +0200 -Subject: [PATCH] 10_linux.in: fix early exit due error when reading petitboot - version - -The script uses bash's read built-in command to get the petitboot version -version, but this command has a non-zero exit status if the EOF is found. - -Since the /sys/firmware/devicetree/base/ibm,firmware-versions/petitboot -string ends with a NUL character, use the empty string as read delimiter -to prevent the command to read to the end-of-file and exit with an error. - -Resolves: rhbz#1827397 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 847646bd8a8..09adfce80fd 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -194,7 +194,7 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" - - if test -e ${petitboot_path}; then -- read -a petitboot_version < ${petitboot_path} -+ read -r -d '' petitboot_version < ${petitboot_path} - petitboot_version="$(echo ${petitboot_version//v})" - major_version="$(echo ${petitboot_version} | cut -d . -f1)" - minor_version="$(echo ${petitboot_version} | cut -d . -f2)" diff --git a/0213-envblk-Fix-buffer-overrun-when-attempting-to-shrink-.patch b/0213-envblk-Fix-buffer-overrun-when-attempting-to-shrink-.patch deleted file mode 100644 index 09d378f..0000000 --- a/0213-envblk-Fix-buffer-overrun-when-attempting-to-shrink-.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 12 May 2020 01:00:51 +0200 -Subject: [PATCH] envblk: Fix buffer overrun when attempting to shrink a - variable value -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -If an existing variable is set with a value whose length is smaller than -the current value, a memory corruption can happen due copying padding '#' -characters outside of the environment block buffer. - -This is caused by a wrong calculation of the previous free space position -after moving backward the characters that followed the old variable value. - -That position is calculated to fill the remaining of the buffer with the -padding '#' characters. But since isn't calculated correctly, it can lead -to copies outside of the buffer. - -The issue can be reproduced by creating a variable with a large value and -then try to set a new value that is much smaller: - -$ grub2-editenv --version -grub2-editenv (GRUB) 2.04 - -$ grub2-editenv env create - -$ grub2-editenv env set a="$(for i in {1..500}; do var="b$var"; done; echo $var)" - -$ wc -c env -1024 grubenv - -$ grub2-editenv env set a="$(for i in {1..50}; do var="b$var"; done; echo $var)" -malloc(): corrupted top size -Aborted (core dumped) - -$ wc -c env -0 grubenv - -Reported-by: Renaud Métrich -Signed-off-by: Javier Martinez Canillas -Patch-cc: Daniel Kiper ---- - grub-core/lib/envblk.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/lib/envblk.c b/grub-core/lib/envblk.c -index f89d86d4e8d..874506da169 100644 ---- a/grub-core/lib/envblk.c -+++ b/grub-core/lib/envblk.c -@@ -143,7 +143,7 @@ grub_envblk_set (grub_envblk_t envblk, const char *name, const char *value) - /* Move the following characters backward, and fill the new - space with harmless characters. */ - grub_memmove (p + vl, p + len, pend - (p + len)); -- grub_memset (space + len - vl, '#', len - vl); -+ grub_memset (space - (len - vl), '#', len - vl); - } - else - /* Move the following characters forward. */ diff --git a/0214-10_linux.in-Store-cmdline-in-BLS-snippets-instead-of.patch b/0214-10_linux.in-Store-cmdline-in-BLS-snippets-instead-of.patch deleted file mode 100644 index 2b9b443..0000000 --- a/0214-10_linux.in-Store-cmdline-in-BLS-snippets-instead-of.patch +++ /dev/null @@ -1,160 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 13 May 2020 19:40:10 +0200 -Subject: [PATCH] 10_linux.in: Store cmdline in BLS snippets instead of using a - variable - -The kernel cmdline was stored as a kernelopts variable in the grubenv file -and the BLS snippets used that. But this turned out to be fragile since the -grubenv file could be removed or get corrupted easily. - -To prevent the entries to not have a cmdline if the grubenv can't be read, -a fallback variable was set in the GRUB config file. But this still caused -issues since the config needs to be re-generated to change the parameters. - -Instead, let's store the cmdline in the BLS snippets. This will make the -configuration more robust, since it will work even without the grubenv -file and the BLS entries will contain all the information needed to boot. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 30 ++++++++++-------------------- - util/grub.d/10_linux.in | 41 +++++++++++++++++++++++++++++++---------- - 2 files changed, 41 insertions(+), 30 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 3333a620c28..cb229126128 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -190,7 +190,7 @@ fi - mkbls() { - local kernelver=$1 && shift - local datetime=$1 && shift -- local bootprefix=$1 && shift -+ local kernelopts=$1 && shift - - local debugname="" - local debugid="" -@@ -209,10 +209,9 @@ mkbls() { - cat <"${bls_target}" -- fi -+ mkbls "${kernelver}" \ -+ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ -+ "${bootprefix}" "${cmdline}" >"${bls_target}" - - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then - bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")" - cp -aT "${bls_target}" "${bls_debug}" - title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" -- blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" -+ options="$(echo "${cmdline} ${GRUB_CMDLINE_LINUX_DEBUG}" | sed -e 's/\//\\\//g')" - sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" -- sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" -- sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" -+ sed -i -e "s/^options.*/options ${options}/" "${bls_debug}" - fi - done - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 09adfce80fd..80299ecaf00 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -134,23 +134,43 @@ read_config() - done < ${config_file} - } - --populate_menu() -+blsdir="/boot/loader/entries" -+ -+get_sorted_bls() - { -- blsdir="/boot/loader/entries" -- local -a files - local IFS=$'\n' -- gettext_printf "Generating boot entries from BLS files...\n" >&2 - -- files=($(for bls in ${blsdir}/*.conf ; do -- if ! [[ -e "${bls}" ]] ; then -- continue -- fi -+ files=($(for bls in ${blsdir}/*.conf; do - bls="${bls%.conf}" - bls="${bls##*/}" - echo "${bls}" - done | ${kernel_sort} | tac)) || : - -- for bls in "${files[@]}" ; do -+ echo "${files[@]}" -+} -+ -+update_bls_cmdline() -+{ -+ local cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" -+ local -a files=($(get_sorted_bls)) -+ -+ for bls in "${files[@]}"; do -+ local options="${cmdline}" -+ if [ -z "${bls##*debug*}" ]; then -+ options="${options} ${GRUB_CMDLINE_LINUX_DEBUG}" -+ fi -+ options="$(echo "${options}" | sed -e 's/\//\\\//g')" -+ sed -i -e "s/^options.*/options ${options}/" "${blsdir}/${bls}.conf" -+ done -+} -+ -+populate_menu() -+{ -+ local -a files=($(get_sorted_bls)) -+ -+ gettext_printf "Generating boot entries from BLS files...\n" >&2 -+ -+ for bls in "${files[@]}"; do - read_config "${blsdir}/${bls}.conf" - - menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" -@@ -224,6 +244,8 @@ if [ -z "\${kernelopts}" ]; then - fi - EOF - -+ update_bls_cmdline -+ - if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then - populate_menu - else -@@ -244,7 +266,6 @@ EOF - fi - fi - -- ${grub_editenv} - set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then - ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" - fi diff --git a/0215-10_linux.in-restore-existence-check-in-get_sorted_bl.patch b/0215-10_linux.in-restore-existence-check-in-get_sorted_bl.patch deleted file mode 100644 index 4517745..0000000 --- a/0215-10_linux.in-restore-existence-check-in-get_sorted_bl.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Adam Williamson -Date: Thu, 14 May 2020 17:52:53 -0700 -Subject: [PATCH] 10_linux.in: restore existence check in `get_sorted_bls` - -This is necessary to handle `/boot/loader/entries` not existing -at all (or possibly existing but being empty - not sure about -that case). Without this check, this function gets pretty wacky -and winds up returning the contents of the current working -directory, which of course causes whatever called it to break. - -Resolves: rhbz#1836020 - -Signed-off-by: Adam Williamson ---- - util/grub.d/10_linux.in | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 80299ecaf00..519e2d9e616 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -141,6 +141,9 @@ get_sorted_bls() - local IFS=$'\n' - - files=($(for bls in ${blsdir}/*.conf; do -+ if ! [[ -e "${bls}" ]] ; then -+ continue -+ fi - bls="${bls%.conf}" - bls="${bls##*/}" - echo "${bls}" diff --git a/0217-tpm-Enable-module-for-all-EFI-platforms.patch b/0217-tpm-Enable-module-for-all-EFI-platforms.patch deleted file mode 100644 index f119785..0000000 --- a/0217-tpm-Enable-module-for-all-EFI-platforms.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 18 May 2020 12:56:27 +0200 -Subject: [PATCH] tpm: Enable module for all EFI platforms - -The tpm module is only enabled for x86_64, but there's nothing specific to -that architecture in the code and could be enabled for all EFI platforms. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/Makefile.core.def | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 661994686e6..b283c502b9c 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -2512,7 +2512,7 @@ module = { - name = tpm; - common = commands/tpm.c; - efi = commands/efi/tpm.c; -- enable = x86_64_efi; -+ enable = efi; - }; - - module = { diff --git a/0218-10_linux.in-Don-t-update-BLS-files-that-aren-t-manag.patch b/0218-10_linux.in-Don-t-update-BLS-files-that-aren-t-manag.patch deleted file mode 100644 index 945efc2..0000000 --- a/0218-10_linux.in-Don-t-update-BLS-files-that-aren-t-manag.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 20 May 2020 12:23:27 +0200 -Subject: [PATCH] 10_linux.in: Don't update BLS files that aren't managed by - GRUB scripts - -The script is updating all BLS files present in the /boot/loader/entries -directory, but it should only update the BLS that belong to the machine. - -Otherwise if a user is sharing the same boot partition between different -operating systems, the grub2-mkconfig tool will wrongly update BLS files -that were created by a different OS. - -There are also cases where the BLS snippets are not managed by the GRUB -scripts at all, for example in OSTree based systems. So it's also wrong -to update the BLS snippets created by OSTree. - -Resolves: rhbz#1837783 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 13 +++++++++++-- - 1 file changed, 11 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 519e2d9e616..e61b6c94f11 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -138,16 +138,25 @@ blsdir="/boot/loader/entries" - - get_sorted_bls() - { -+ if ! [ -d "${blsdir}" ] || ! [ -e /etc/machine-id ]; then -+ return -+ fi -+ -+ read machine_id < /etc/machine-id -+ if [ -z "${machine_id}" ]; then -+ return -+ fi -+ - local IFS=$'\n' - -- files=($(for bls in ${blsdir}/*.conf; do -+ files=($(for bls in ${blsdir}/${machine_id}-*.conf; do - if ! [[ -e "${bls}" ]] ; then - continue - fi - bls="${bls%.conf}" - bls="${bls##*/}" - echo "${bls}" -- done | ${kernel_sort} | tac)) || : -+ done | ${kernel_sort} 2>/dev/null | tac)) || : - - echo "${files[@]}" - } diff --git a/0221-fix-build-with-rpm-4.16.patch b/0221-fix-build-with-rpm-4.16.patch deleted file mode 100644 index 2a2e389..0000000 --- a/0221-fix-build-with-rpm-4.16.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Thierry Vignaud -Date: Mon, 8 Jun 2020 06:50:21 +0200 -Subject: [PATCH] fix build with rpm-4.16 - -Signed-off-by: Thierry Vignaud ---- - configure.ac | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/configure.ac b/configure.ac -index eff160b6931..5d3316185da 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1887,6 +1887,15 @@ if test x"$rpm_sort_excuse" = x ; then - [Define to 1 if you have the rpm library.]) - fi - -+if test x"$LIBRPM" = x ; then -+ # Check for rpm library. -+ AC_CHECK_LIB([rpmio], [rpmvercmp], [], -+ [rpm_sort_excuse="rpmio missing rpmvercmp"]) -+ LIBRPM="-lrpmio"; -+ AC_DEFINE([HAVE_RPMIO], [1], -+ [Define to 1 if you have the rpm library.]) -+fi -+ - AC_SUBST([LIBRPM]) - - LIBGEOM= diff --git a/0222-Only-mark-GRUB-as-BLS-supported-in-OSTree-systems-wi.patch b/0222-Only-mark-GRUB-as-BLS-supported-in-OSTree-systems-wi.patch deleted file mode 100644 index dbb24f2..0000000 --- a/0222-Only-mark-GRUB-as-BLS-supported-in-OSTree-systems-wi.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 18 Jun 2020 11:19:00 +0200 -Subject: [PATCH] Only mark GRUB as BLS supported in OSTree systems with a boot - partition - -The script grub2-switch-to-blscfg updates the grub2 EFI binary in OSTree -systems and marks that has BLS support, to indicate that's not necessary -to add menuentry commands since the BLS snippets can be used to populate -the GRUB boot menu. - -But OSTree doesn't support installations that don't have a boot partition, -the BLS snippets assume that there will be one so this has to be checked -and only mark the bootloader as supporting BLS in OSTree installations -that have /boot as a mountpoint. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index cb229126128..a851424beb2 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -261,7 +261,8 @@ copy_bls() { - # but only do this if the blsdir is not set, to make sure that the BLS - # parsing module will search for the BLS snippets in the default path. - if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \ -- ! ${grub_editenv} - list | grep -q blsdir; then -+ ! ${grub_editenv} - list | grep -q blsdir && \ -+ mountpoint -q /boot; then - grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" - install -m 700 ${grub_binary} ${grubdir} || exit 1 - # Create a hidden file to indicate that grub2 now has BLS support. diff --git a/0223-Don-t-assume-that-boot-commands-will-only-return-on-.patch b/0223-Don-t-assume-that-boot-commands-will-only-return-on-.patch deleted file mode 100644 index 5dc6377..0000000 --- a/0223-Don-t-assume-that-boot-commands-will-only-return-on-.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 9 Apr 2019 13:12:40 +0200 -Subject: [PATCH] Don't assume that boot commands will only return on fail - -While it's true that for most loaders the boot command never returns, it -may be the case that it does. For example the GRUB emulator boot command -calls to systemctl kexec which in turn does an asynchonous call to kexec. - -So in this case GRUB will wrongly assume that the boot command fails and -print a "Failed to boot both default and fallback entries" even when the -kexec call later succeeds. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/normal/menu.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 9ea1f411814..14ceb9bb060 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -302,7 +302,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) - { - grub_print_error (); - grub_errno = GRUB_ERR_NONE; -- return; -+ return grub_errno; - } - - errs_before = grub_err_printed_errors; -@@ -315,7 +315,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) - grub_env_context_open (); - menu = grub_zalloc (sizeof (*menu)); - if (! menu) -- return; -+ return grub_errno; - grub_env_set_menu (menu); - if (auto_boot) - grub_env_set ("timeout", "0"); diff --git a/0225-yylex-Make-lexer-fatal-errors-actually-be-fatal.patch b/0225-yylex-Make-lexer-fatal-errors-actually-be-fatal.patch deleted file mode 100644 index 99b66f0..0000000 --- a/0225-yylex-Make-lexer-fatal-errors-actually-be-fatal.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 15 Apr 2020 15:45:02 -0400 -Subject: [PATCH] yylex: Make lexer fatal errors actually be fatal - -When presented with a command that can't be tokenized to anything -smaller than YYLMAX characters, the parser calls YY_FATAL_ERROR(errmsg), -expecting that will stop further processing, as such: - - #define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - if ( yyleng >= YYLMAX ) \ - YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ - yy_flex_strncpy( yytext, yyg->yytext_ptr, yyleng + 1 , yyscanner); \ - yyg->yy_c_buf_p = yy_cp; - -The code flex generates expects that YY_FATAL_ERROR() will either return -for it or do some form of longjmp(), or handle the error in some way at -least, and so the strncpy() call isn't in an "else" clause, and thus if -YY_FATAL_ERROR() is *not* actually fatal, it does the call with the -questionable limit, and predictable results ensue. - -Unfortunately, our implementation of YY_FATAL_ERROR() is: - - #define YY_FATAL_ERROR(msg) \ - do { \ - grub_printf (_("fatal error: %s\n"), _(msg)); \ - } while (0) - -The same pattern exists in yyless(), and similar problems exist in users -of YY_INPUT(), several places in the main parsing loop, -yy_get_next_buffer(), yy_load_buffer_state(), yyensure_buffer_stack, -yy_scan_buffer(), etc. - -All of these callers expect YY_FATAL_ERROR() to actually be fatal, and -the things they do if it returns after calling it are wildly unsafe. - -Fixes: CVE-2020-10713 - -Signed-off-by: Peter Jones -Reviewed-by: Daniel Kiper -Upstream-commit-id: 926df817dc8 ---- - grub-core/script/yylex.l | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l -index 7b44c37b76f..b7203c82309 100644 ---- a/grub-core/script/yylex.l -+++ b/grub-core/script/yylex.l -@@ -37,11 +37,11 @@ - - /* - * As we don't have access to yyscanner, we cannot do much except to -- * print the fatal error. -+ * print the fatal error and exit. - */ - #define YY_FATAL_ERROR(msg) \ - do { \ -- grub_printf (_("fatal error: %s\n"), _(msg)); \ -+ grub_fatal (_("fatal error: %s\n"), _(msg));\ - } while (0) - - #define COPY(str, hint) \ diff --git a/0226-safemath-Add-some-arithmetic-primitives-that-check-f.patch b/0226-safemath-Add-some-arithmetic-primitives-that-check-f.patch deleted file mode 100644 index 2478686..0000000 --- a/0226-safemath-Add-some-arithmetic-primitives-that-check-f.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 15 Jun 2020 10:58:42 -0400 -Subject: [PATCH] safemath: Add some arithmetic primitives that check for - overflow - -This adds a new header, include/grub/safemath.h, that includes easy to -use wrappers for __builtin_{add,sub,mul}_overflow() declared like: - - bool OP(a, b, res) - -where OP is grub_add, grub_sub or grub_mul. OP() returns true in the -case where the operation would overflow and res is not modified. -Otherwise, false is returned and the operation is executed. - -These arithmetic primitives require newer compiler versions. So, bump -these requirements in the INSTALL file too. - -Signed-off-by: Peter Jones -Reviewed-by: Daniel Kiper -Upstream-commit-id: de1c315841a ---- - include/grub/compiler.h | 8 ++++++++ - include/grub/safemath.h | 37 +++++++++++++++++++++++++++++++++++++ - INSTALL | 22 ++-------------------- - 3 files changed, 47 insertions(+), 20 deletions(-) - create mode 100644 include/grub/safemath.h - -diff --git a/include/grub/compiler.h b/include/grub/compiler.h -index 9859ff4cc79..ebafec68957 100644 ---- a/include/grub/compiler.h -+++ b/include/grub/compiler.h -@@ -48,6 +48,14 @@ - # define WARN_UNUSED_RESULT - #endif - -+#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__) -+# define CLANG_PREREQ(maj,min) \ -+ ((__clang_major__ > (maj)) || \ -+ (__clang_major__ == (maj) && __clang_minor__ >= (min))) -+#else -+# define CLANG_PREREQ(maj,min) 0 -+#endif -+ - #define UNUSED __attribute__((__unused__)) - - #endif /* ! GRUB_COMPILER_HEADER */ -diff --git a/include/grub/safemath.h b/include/grub/safemath.h -new file mode 100644 -index 00000000000..c17b89bba17 ---- /dev/null -+++ b/include/grub/safemath.h -@@ -0,0 +1,37 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2020 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ * -+ * Arithmetic operations that protect against overflow. -+ */ -+ -+#ifndef GRUB_SAFEMATH_H -+#define GRUB_SAFEMATH_H 1 -+ -+#include -+ -+/* These appear in gcc 5.1 and clang 3.8. */ -+#if GNUC_PREREQ(5, 1) || CLANG_PREREQ(3, 8) -+ -+#define grub_add(a, b, res) __builtin_add_overflow(a, b, res) -+#define grub_sub(a, b, res) __builtin_sub_overflow(a, b, res) -+#define grub_mul(a, b, res) __builtin_mul_overflow(a, b, res) -+ -+#else -+#error gcc 5.1 or newer or clang 3.8 or newer is required -+#endif -+ -+#endif /* GRUB_SAFEMATH_H */ -diff --git a/INSTALL b/INSTALL -index 8acb4090235..dcb9b7d7b7a 100644 ---- a/INSTALL -+++ b/INSTALL -@@ -11,27 +11,9 @@ GRUB depends on some software packages installed into your system. If - you don't have any of them, please obtain and install them before - configuring the GRUB. - --* GCC 4.1.3 or later -- Note: older versions may work but support is limited -- -- Experimental support for clang 3.3 or later (results in much bigger binaries) -+* GCC 5.1.0 or later -+ Experimental support for clang 3.8.0 or later (results in much bigger binaries) - for i386, x86_64, arm (including thumb), arm64, mips(el), powerpc, sparc64 -- Note: clang 3.2 or later works for i386 and x86_64 targets but results in -- much bigger binaries. -- earlier versions not tested -- Note: clang 3.2 or later works for arm -- earlier versions not tested -- Note: clang on arm64 is not supported due to -- https://llvm.org/bugs/show_bug.cgi?id=26030 -- Note: clang 3.3 or later works for mips(el) -- earlier versions fail to generate .reginfo and hence gprel relocations -- fail. -- Note: clang 3.2 or later works for powerpc -- earlier versions not tested -- Note: clang 3.5 or later works for sparc64 -- earlier versions return "error: unable to interface with target machine" -- Note: clang has no support for ia64 and hence you can't compile GRUB -- for ia64 with clang - * GNU Make - * GNU Bison 2.3 or later - * GNU gettext 0.17 or later diff --git a/0227-calloc-Make-sure-we-always-have-an-overflow-checking.patch b/0227-calloc-Make-sure-we-always-have-an-overflow-checking.patch deleted file mode 100644 index b44695b..0000000 --- a/0227-calloc-Make-sure-we-always-have-an-overflow-checking.patch +++ /dev/null @@ -1,240 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 15 Jun 2020 12:15:29 -0400 -Subject: [PATCH] calloc: Make sure we always have an overflow-checking - calloc() available - -This tries to make sure that everywhere in this source tree, we always have -an appropriate version of calloc() (i.e. grub_calloc(), xcalloc(), etc.) -available, and that they all safely check for overflow and return NULL when -it would occur. - -Signed-off-by: Peter Jones -Reviewed-by: Daniel Kiper -Upstream-commit-id: 79e51ab7a9a ---- - grub-core/kern/emu/misc.c | 12 ++++++++++++ - grub-core/kern/emu/mm.c | 10 ++++++++++ - grub-core/kern/mm.c | 40 ++++++++++++++++++++++++++++++++++++++ - grub-core/lib/libgcrypt_wrap/mem.c | 11 +++++++++-- - grub-core/lib/posix_wrap/stdlib.h | 8 +++++++- - include/grub/emu/misc.h | 1 + - include/grub/mm.h | 6 ++++++ - 7 files changed, 85 insertions(+), 3 deletions(-) - -diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index 7a8d9e62300..f08a1bb8415 100644 ---- a/grub-core/kern/emu/misc.c -+++ b/grub-core/kern/emu/misc.c -@@ -86,6 +86,18 @@ grub_util_error (const char *fmt, ...) - grub_exit (1); - } - -+void * -+xcalloc (grub_size_t nmemb, grub_size_t size) -+{ -+ void *p; -+ -+ p = calloc (nmemb, size); -+ if (!p) -+ grub_util_error ("%s", _("out of memory")); -+ -+ return p; -+} -+ - void * - xmalloc (grub_size_t size) - { -diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c -index f262e95e388..145b01d3719 100644 ---- a/grub-core/kern/emu/mm.c -+++ b/grub-core/kern/emu/mm.c -@@ -25,6 +25,16 @@ - #include - #include - -+void * -+grub_calloc (grub_size_t nmemb, grub_size_t size) -+{ -+ void *ret; -+ ret = calloc (nmemb, size); -+ if (!ret) -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ return ret; -+} -+ - void * - grub_malloc (grub_size_t size) - { -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index 002cbfa4f3d..80d0720d005 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -67,8 +67,10 @@ - #include - #include - #include -+#include - - #ifdef MM_DEBUG -+# undef grub_calloc - # undef grub_malloc - # undef grub_zalloc - # undef grub_realloc -@@ -375,6 +377,30 @@ grub_memalign (grub_size_t align, grub_size_t size) - return 0; - } - -+/* -+ * Allocate NMEMB instances of SIZE bytes and return the pointer, or error on -+ * integer overflow. -+ */ -+void * -+grub_calloc (grub_size_t nmemb, grub_size_t size) -+{ -+ void *ret; -+ grub_size_t sz = 0; -+ -+ if (grub_mul (nmemb, size, &sz)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ return NULL; -+ } -+ -+ ret = grub_memalign (0, sz); -+ if (!ret) -+ return NULL; -+ -+ grub_memset (ret, 0, sz); -+ return ret; -+} -+ - /* Allocate SIZE bytes and return the pointer. */ - void * - grub_malloc (grub_size_t size) -@@ -561,6 +587,20 @@ grub_mm_dump (unsigned lineno) - grub_printf ("\n"); - } - -+void * -+grub_debug_calloc (const char *file, int line, grub_size_t nmemb, grub_size_t size) -+{ -+ void *ptr; -+ -+ if (grub_mm_debug) -+ grub_printf ("%s:%d: calloc (0x%" PRIxGRUB_SIZE ", 0x%" PRIxGRUB_SIZE ") = ", -+ file, line, size); -+ ptr = grub_calloc (nmemb, size); -+ if (grub_mm_debug) -+ grub_printf ("%p\n", ptr); -+ return ptr; -+} -+ - void * - grub_debug_malloc (const char *file, int line, grub_size_t size) - { -diff --git a/grub-core/lib/libgcrypt_wrap/mem.c b/grub-core/lib/libgcrypt_wrap/mem.c -index beeb661a3c8..74c6eafe525 100644 ---- a/grub-core/lib/libgcrypt_wrap/mem.c -+++ b/grub-core/lib/libgcrypt_wrap/mem.c -@@ -4,6 +4,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -36,7 +37,10 @@ void * - gcry_xcalloc (size_t n, size_t m) - { - void *ret; -- ret = grub_zalloc (n * m); -+ size_t sz; -+ if (grub_mul (n, m, &sz)) -+ grub_fatal ("gcry_xcalloc would overflow"); -+ ret = grub_zalloc (sz); - if (!ret) - grub_fatal ("gcry_xcalloc failed"); - return ret; -@@ -56,7 +60,10 @@ void * - gcry_xcalloc_secure (size_t n, size_t m) - { - void *ret; -- ret = grub_zalloc (n * m); -+ size_t sz; -+ if (grub_mul (n, m, &sz)) -+ grub_fatal ("gcry_xcalloc would overflow"); -+ ret = grub_zalloc (sz); - if (!ret) - grub_fatal ("gcry_xcalloc failed"); - return ret; -diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h -index 3b46f47ff50..7a8d385e973 100644 ---- a/grub-core/lib/posix_wrap/stdlib.h -+++ b/grub-core/lib/posix_wrap/stdlib.h -@@ -21,6 +21,7 @@ - - #include - #include -+#include - - static inline void - free (void *ptr) -@@ -37,7 +38,12 @@ malloc (grub_size_t size) - static inline void * - calloc (grub_size_t size, grub_size_t nelem) - { -- return grub_zalloc (size * nelem); -+ grub_size_t sz; -+ -+ if (grub_mul (size, nelem, &sz)) -+ return NULL; -+ -+ return grub_zalloc (sz); - } - - static inline void * -diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h -index 5ef4f79e689..01056954b96 100644 ---- a/include/grub/emu/misc.h -+++ b/include/grub/emu/misc.h -@@ -47,6 +47,7 @@ grub_util_device_is_mapped (const char *dev); - #define GRUB_HOST_PRIuLONG_LONG "llu" - #define GRUB_HOST_PRIxLONG_LONG "llx" - -+void * EXPORT_FUNC(xcalloc) (grub_size_t nmemb, grub_size_t size) WARN_UNUSED_RESULT; - void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT; - void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT; - char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT; -diff --git a/include/grub/mm.h b/include/grub/mm.h -index 28e2e53eb32..9c38dd3ca5d 100644 ---- a/include/grub/mm.h -+++ b/include/grub/mm.h -@@ -29,6 +29,7 @@ - #endif - - void grub_mm_init_region (void *addr, grub_size_t size); -+void *EXPORT_FUNC(grub_calloc) (grub_size_t nmemb, grub_size_t size); - void *EXPORT_FUNC(grub_malloc) (grub_size_t size); - void *EXPORT_FUNC(grub_zalloc) (grub_size_t size); - void EXPORT_FUNC(grub_free) (void *ptr); -@@ -48,6 +49,9 @@ extern int EXPORT_VAR(grub_mm_debug); - void grub_mm_dump_free (void); - void grub_mm_dump (unsigned lineno); - -+#define grub_calloc(nmemb, size) \ -+ grub_debug_calloc (GRUB_FILE, __LINE__, nmemb, size) -+ - #define grub_malloc(size) \ - grub_debug_malloc (GRUB_FILE, __LINE__, size) - -@@ -63,6 +67,8 @@ void grub_mm_dump (unsigned lineno); - #define grub_free(ptr) \ - grub_debug_free (GRUB_FILE, __LINE__, ptr) - -+void *EXPORT_FUNC(grub_debug_calloc) (const char *file, int line, -+ grub_size_t nmemb, grub_size_t size); - void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line, - grub_size_t size); - void *EXPORT_FUNC(grub_debug_zalloc) (const char *file, int line, diff --git a/0228-calloc-Use-calloc-at-most-places.patch b/0228-calloc-Use-calloc-at-most-places.patch deleted file mode 100644 index 6d42930..0000000 --- a/0228-calloc-Use-calloc-at-most-places.patch +++ /dev/null @@ -1,1834 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 15 Jun 2020 12:26:01 -0400 -Subject: [PATCH] calloc: Use calloc() at most places - -This modifies most of the places we do some form of: - - X = malloc(Y * Z); - -to use calloc(Y, Z) instead. - -Among other issues, this fixes: - - allocation of integer overflow in grub_png_decode_image_header() - reported by Chris Coulson, - - allocation of integer overflow in luks_recover_key() - reported by Chris Coulson, - - allocation of integer overflow in grub_lvm_detect() - reported by Chris Coulson. - -Fixes: CVE-2020-14308 - -Signed-off-by: Peter Jones -Reviewed-by: Daniel Kiper -Upstream-commit-id: 48eeedf1e4b ---- - grub-core/bus/usb/usbhub.c | 8 ++++---- - grub-core/commands/efi/lsefisystab.c | 3 ++- - grub-core/commands/legacycfg.c | 6 +++--- - grub-core/commands/menuentry.c | 2 +- - grub-core/commands/nativedisk.c | 2 +- - grub-core/commands/parttool.c | 12 +++++++++--- - grub-core/commands/regexp.c | 2 +- - grub-core/commands/search_wrap.c | 2 +- - grub-core/disk/diskfilter.c | 4 ++-- - grub-core/disk/ieee1275/ofdisk.c | 2 +- - grub-core/disk/ldm.c | 14 +++++++------- - grub-core/disk/luks.c | 2 +- - grub-core/disk/lvm.c | 8 ++++---- - grub-core/disk/xen/xendisk.c | 2 +- - grub-core/efiemu/loadcore.c | 2 +- - grub-core/efiemu/mm.c | 6 +++--- - grub-core/font/font.c | 3 +-- - grub-core/fs/affs.c | 6 +++--- - grub-core/fs/btrfs.c | 6 +++--- - grub-core/fs/hfs.c | 2 +- - grub-core/fs/hfsplus.c | 6 +++--- - grub-core/fs/iso9660.c | 2 +- - grub-core/fs/ntfs.c | 4 ++-- - grub-core/fs/sfs.c | 2 +- - grub-core/fs/tar.c | 2 +- - grub-core/fs/udf.c | 4 ++-- - grub-core/fs/zfs/zfs.c | 4 ++-- - grub-core/gfxmenu/gui_string_util.c | 2 +- - grub-core/gfxmenu/widget-box.c | 4 ++-- - grub-core/io/gzio.c | 2 +- - grub-core/kern/efi/efi.c | 6 +++--- - grub-core/kern/emu/hostdisk.c | 2 +- - grub-core/kern/fs.c | 2 +- - grub-core/kern/misc.c | 2 +- - grub-core/kern/parser.c | 2 +- - grub-core/kern/uboot/uboot.c | 2 +- - grub-core/lib/libgcrypt/cipher/ac.c | 8 ++++---- - grub-core/lib/libgcrypt/cipher/primegen.c | 4 ++-- - grub-core/lib/libgcrypt/cipher/pubkey.c | 4 ++-- - grub-core/lib/priority_queue.c | 2 +- - grub-core/lib/reed_solomon.c | 7 +++---- - grub-core/lib/relocator.c | 10 +++++----- - grub-core/lib/zstd/fse_decompress.c | 2 +- - grub-core/loader/arm/linux.c | 2 +- - grub-core/loader/efi/chainloader.c | 2 +- - grub-core/loader/i386/bsdXX.c | 2 +- - grub-core/loader/i386/xnu.c | 4 ++-- - grub-core/loader/macho.c | 2 +- - grub-core/loader/multiboot_elfxx.c | 2 +- - grub-core/loader/xnu.c | 2 +- - grub-core/mmap/mmap.c | 4 ++-- - grub-core/net/bootp.c | 2 +- - grub-core/net/dns.c | 10 +++++----- - grub-core/net/net.c | 4 ++-- - grub-core/normal/charset.c | 10 +++++----- - grub-core/normal/cmdline.c | 14 +++++++------- - grub-core/normal/menu_entry.c | 14 +++++++------- - grub-core/normal/menu_text.c | 4 ++-- - grub-core/normal/term.c | 4 ++-- - grub-core/osdep/linux/getroot.c | 6 +++--- - grub-core/osdep/unix/config.c | 2 +- - grub-core/osdep/windows/getroot.c | 2 +- - grub-core/osdep/windows/hostdisk.c | 4 ++-- - grub-core/osdep/windows/init.c | 2 +- - grub-core/osdep/windows/platform.c | 4 ++-- - grub-core/osdep/windows/relpath.c | 2 +- - grub-core/partmap/gpt.c | 2 +- - grub-core/partmap/msdos.c | 2 +- - grub-core/script/execute.c | 2 +- - grub-core/tests/fake_input.c | 2 +- - grub-core/tests/video_checksum.c | 6 +++--- - grub-core/video/capture.c | 2 +- - grub-core/video/emu/sdl.c | 2 +- - grub-core/video/i386/pc/vga.c | 2 +- - grub-core/video/readers/png.c | 2 +- - util/getroot.c | 2 +- - util/grub-file.c | 2 +- - util/grub-fstest.c | 4 ++-- - util/grub-install-common.c | 2 +- - util/grub-install.c | 4 ++-- - util/grub-mkimagexx.c | 6 ++---- - util/grub-mkrescue.c | 4 ++-- - util/grub-mkstandalone.c | 2 +- - util/grub-pe2elf.c | 12 +++++------- - util/grub-probe.c | 4 ++-- - include/grub/unicode.h | 4 ++-- - 86 files changed, 176 insertions(+), 175 deletions(-) - -diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c -index 34a7ff1b5f8..a06cce302d2 100644 ---- a/grub-core/bus/usb/usbhub.c -+++ b/grub-core/bus/usb/usbhub.c -@@ -149,8 +149,8 @@ grub_usb_add_hub (grub_usb_device_t dev) - grub_usb_set_configuration (dev, 1); - - dev->nports = hubdesc.portcnt; -- dev->children = grub_zalloc (hubdesc.portcnt * sizeof (dev->children[0])); -- dev->ports = grub_zalloc (dev->nports * sizeof (dev->ports[0])); -+ dev->children = grub_calloc (hubdesc.portcnt, sizeof (dev->children[0])); -+ dev->ports = grub_calloc (dev->nports, sizeof (dev->ports[0])); - if (!dev->children || !dev->ports) - { - grub_free (dev->children); -@@ -268,8 +268,8 @@ grub_usb_controller_dev_register_iter (grub_usb_controller_t controller, void *d - - /* Query the number of ports the root Hub has. */ - hub->nports = controller->dev->hubports (controller); -- hub->devices = grub_zalloc (sizeof (hub->devices[0]) * hub->nports); -- hub->ports = grub_zalloc (sizeof (hub->ports[0]) * hub->nports); -+ hub->devices = grub_calloc (hub->nports, sizeof (hub->devices[0])); -+ hub->ports = grub_calloc (hub->nports, sizeof (hub->ports[0])); - if (!hub->devices || !hub->ports) - { - grub_free (hub->devices); -diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c -index df103022188..cd81507f5d4 100644 ---- a/grub-core/commands/efi/lsefisystab.c -+++ b/grub-core/commands/efi/lsefisystab.c -@@ -71,7 +71,8 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)), - grub_printf ("Vendor: "); - - for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++); -- vendor = grub_malloc (4 * (vendor_utf16 - st->firmware_vendor) + 1); -+ /* Allocate extra 3 bytes to simplify math. */ -+ vendor = grub_calloc (4, vendor_utf16 - st->firmware_vendor + 1); - if (!vendor) - return grub_errno; - *grub_utf16_to_utf8 ((grub_uint8_t *) vendor, st->firmware_vendor, -diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c -index 891eac5a33f..da5143d4360 100644 ---- a/grub-core/commands/legacycfg.c -+++ b/grub-core/commands/legacycfg.c -@@ -315,7 +315,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), - if (argc < 2) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - -- cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1)); -+ cutargs = grub_calloc (argc - 1, sizeof (cutargs[0])); - if (!cutargs) - return grub_errno; - cutargc = argc - 1; -@@ -437,7 +437,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), - { - char rbuf[3] = "-r"; - bsdargc = cutargc + 2; -- bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc); -+ bsdargs = grub_calloc (bsdargc, sizeof (bsdargs[0])); - if (!bsdargs) - { - err = grub_errno; -@@ -560,7 +560,7 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"), - "module"); - -- newargs = grub_malloc ((argc + 1) * sizeof (newargs[0])); -+ newargs = grub_calloc (argc + 1, sizeof (newargs[0])); - if (!newargs) - return grub_errno; - grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0])); -diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index 29736f5cd03..84edfc06b7f 100644 ---- a/grub-core/commands/menuentry.c -+++ b/grub-core/commands/menuentry.c -@@ -157,7 +157,7 @@ grub_normal_add_menu_entry (int argc, const char **args, - grub_dprintf ("menu", "menu_id:\"%s\"\n", menu_id); - - /* Save argc, args to pass as parameters to block arg later. */ -- menu_args = grub_malloc (sizeof (char*) * (argc + 1)); -+ menu_args = grub_calloc (argc + 1, sizeof (char *)); - if (! menu_args) - goto fail; - -diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c -index 699447d11ec..7c8f97f6ad5 100644 ---- a/grub-core/commands/nativedisk.c -+++ b/grub-core/commands/nativedisk.c -@@ -195,7 +195,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), - else - path_prefix = prefix; - -- mods = grub_malloc (argc * sizeof (mods[0])); -+ mods = grub_calloc (argc, sizeof (mods[0])); - if (!mods) - return grub_errno; - -diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c -index 22b46b18741..051e31320e9 100644 ---- a/grub-core/commands/parttool.c -+++ b/grub-core/commands/parttool.c -@@ -59,7 +59,13 @@ grub_parttool_register(const char *part_name, - for (nargs = 0; args[nargs].name != 0; nargs++); - cur->nargs = nargs; - cur->args = (struct grub_parttool_argdesc *) -- grub_malloc ((nargs + 1) * sizeof (struct grub_parttool_argdesc)); -+ grub_calloc (nargs + 1, sizeof (struct grub_parttool_argdesc)); -+ if (!cur->args) -+ { -+ grub_free (cur); -+ curhandle--; -+ return -1; -+ } - grub_memcpy (cur->args, args, - (nargs + 1) * sizeof (struct grub_parttool_argdesc)); - -@@ -257,7 +263,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), - return err; - } - -- parsed = (int *) grub_zalloc (argc * sizeof (int)); -+ parsed = (int *) grub_calloc (argc, sizeof (int)); - - for (i = 1; i < argc; i++) - if (! parsed[i]) -@@ -290,7 +296,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), - } - ptool = cur; - pargs = (struct grub_parttool_args *) -- grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args)); -+ grub_calloc (ptool->nargs, sizeof (struct grub_parttool_args)); - for (j = i; j < argc; j++) - if (! parsed[j]) - { -diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c -index 7c5c72fe460..612003f94c8 100644 ---- a/grub-core/commands/regexp.c -+++ b/grub-core/commands/regexp.c -@@ -116,7 +116,7 @@ grub_cmd_regexp (grub_extcmd_context_t ctxt, int argc, char **args) - if (ret) - goto fail; - -- matches = grub_zalloc (sizeof (*matches) * (regex.re_nsub + 1)); -+ matches = grub_calloc (regex.re_nsub + 1, sizeof (*matches)); - if (! matches) - goto fail; - -diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c -index d7fd26b9405..47fc8eb9966 100644 ---- a/grub-core/commands/search_wrap.c -+++ b/grub-core/commands/search_wrap.c -@@ -122,7 +122,7 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args) - for (i = 0; state[SEARCH_HINT_BAREMETAL].args[i]; i++) - nhints++; - -- hints = grub_malloc (sizeof (hints[0]) * nhints); -+ hints = grub_calloc (nhints, sizeof (hints[0])); - if (!hints) - return grub_errno; - j = 0; -diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c -index 3f264be77d1..88784dc440b 100644 ---- a/grub-core/disk/diskfilter.c -+++ b/grub-core/disk/diskfilter.c -@@ -1137,7 +1137,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, - array->lvs->segments->node_count = nmemb; - array->lvs->segments->raid_member_size = disk_size; - array->lvs->segments->nodes -- = grub_zalloc (nmemb * sizeof (array->lvs->segments->nodes[0])); -+ = grub_calloc (nmemb, sizeof (array->lvs->segments->nodes[0])); - array->lvs->segments->stripe_size = stripe_size; - for (i = 0; i < nmemb; i++) - { -@@ -1230,7 +1230,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id, - grub_partition_t p; - for (p = disk->partition; p; p = p->parent) - s++; -- pv->partmaps = xmalloc (s * sizeof (pv->partmaps[0])); -+ pv->partmaps = xcalloc (s, sizeof (pv->partmaps[0])); - s = 0; - for (p = disk->partition; p; p = p->parent) - pv->partmaps[s++] = xstrdup (p->partmap->name); -diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c -index f73257e66dc..03674cb477e 100644 ---- a/grub-core/disk/ieee1275/ofdisk.c -+++ b/grub-core/disk/ieee1275/ofdisk.c -@@ -297,7 +297,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) - /* Power machines documentation specify 672 as maximum SAS disks in - one system. Using a slightly larger value to be safe. */ - table_size = 768; -- table = grub_malloc (table_size * sizeof (grub_uint64_t)); -+ table = grub_calloc (table_size, sizeof (grub_uint64_t)); - - if (!table) - { -diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c -index 2a22d2d6c1c..e6323701ab3 100644 ---- a/grub-core/disk/ldm.c -+++ b/grub-core/disk/ldm.c -@@ -323,8 +323,8 @@ make_vg (grub_disk_t disk, - lv->segments->type = GRUB_DISKFILTER_MIRROR; - lv->segments->node_count = 0; - lv->segments->node_alloc = 8; -- lv->segments->nodes = grub_zalloc (sizeof (*lv->segments->nodes) -- * lv->segments->node_alloc); -+ lv->segments->nodes = grub_calloc (lv->segments->node_alloc, -+ sizeof (*lv->segments->nodes)); - if (!lv->segments->nodes) - goto fail2; - ptr = vblk[i].dynamic; -@@ -543,8 +543,8 @@ make_vg (grub_disk_t disk, - { - comp->segment_alloc = 8; - comp->segment_count = 0; -- comp->segments = grub_malloc (sizeof (*comp->segments) -- * comp->segment_alloc); -+ comp->segments = grub_calloc (comp->segment_alloc, -+ sizeof (*comp->segments)); - if (!comp->segments) - goto fail2; - } -@@ -590,8 +590,8 @@ make_vg (grub_disk_t disk, - } - comp->segments->node_count = read_int (ptr + 1, *ptr); - comp->segments->node_alloc = comp->segments->node_count; -- comp->segments->nodes = grub_zalloc (sizeof (*comp->segments->nodes) -- * comp->segments->node_alloc); -+ comp->segments->nodes = grub_calloc (comp->segments->node_alloc, -+ sizeof (*comp->segments->nodes)); - if (!lv->segments->nodes) - goto fail2; - } -@@ -1017,7 +1017,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors, - *nsectors = lv->size; - if (*nsectors > max_nsectors) - *nsectors = max_nsectors; -- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); -+ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); - if (!*sectors) - return grub_errno; - for (i = 0; i < *nsectors; i++) -diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c -index 86c50c61217..18b3a8bb1d3 100644 ---- a/grub-core/disk/luks.c -+++ b/grub-core/disk/luks.c -@@ -336,7 +336,7 @@ luks_recover_key (grub_disk_t source, - && grub_be_to_cpu32 (header.keyblock[i].stripes) > max_stripes) - max_stripes = grub_be_to_cpu32 (header.keyblock[i].stripes); - -- split_key = grub_malloc (keysize * max_stripes); -+ split_key = grub_calloc (keysize, max_stripes); - if (!split_key) - return grub_errno; - -diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c -index 0cbd0dd1629..8e76d1ae121 100644 ---- a/grub-core/disk/lvm.c -+++ b/grub-core/disk/lvm.c -@@ -174,7 +174,7 @@ grub_lvm_detect (grub_disk_t disk, - first one. */ - - /* Allocate buffer space for the circular worst-case scenario. */ -- metadatabuf = grub_malloc (2 * mda_size); -+ metadatabuf = grub_calloc (2, mda_size); - if (! metadatabuf) - goto fail; - -@@ -427,7 +427,7 @@ grub_lvm_detect (grub_disk_t disk, - #endif - goto lvs_fail; - } -- lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count); -+ lv->segments = grub_calloc (lv->segment_count, sizeof (*seg)); - seg = lv->segments; - - for (i = 0; i < lv->segment_count; i++) -@@ -484,8 +484,8 @@ grub_lvm_detect (grub_disk_t disk, - if (seg->node_count != 1) - seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); - -- seg->nodes = grub_zalloc (sizeof (*stripe) -- * seg->node_count); -+ seg->nodes = grub_calloc (seg->node_count, -+ sizeof (*stripe)); - stripe = seg->nodes; - - p = grub_strstr (p, "stripes = ["); -diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c -index 48476cbbf96..d6612eebd75 100644 ---- a/grub-core/disk/xen/xendisk.c -+++ b/grub-core/disk/xen/xendisk.c -@@ -426,7 +426,7 @@ grub_xendisk_init (void) - if (!ctr) - return; - -- virtdisks = grub_malloc (ctr * sizeof (virtdisks[0])); -+ virtdisks = grub_calloc (ctr, sizeof (virtdisks[0])); - if (!virtdisks) - return; - if (grub_xenstore_dir ("device/vbd", fill, &ctr)) -diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c -index 44085ef818e..2b924623f51 100644 ---- a/grub-core/efiemu/loadcore.c -+++ b/grub-core/efiemu/loadcore.c -@@ -201,7 +201,7 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e) - - grub_efiemu_nelfsyms = (unsigned) s->sh_size / (unsigned) s->sh_entsize; - grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *) -- grub_malloc (sizeof (struct grub_efiemu_elf_sym) * grub_efiemu_nelfsyms); -+ grub_calloc (grub_efiemu_nelfsyms, sizeof (struct grub_efiemu_elf_sym)); - - /* Relocators */ - for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); -diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c -index 52a032f7b2e..9b8e0d0ad1a 100644 ---- a/grub-core/efiemu/mm.c -+++ b/grub-core/efiemu/mm.c -@@ -554,11 +554,11 @@ grub_efiemu_mmap_sort_and_uniq (void) - /* Initialize variables*/ - grub_memset (present, 0, sizeof (int) * GRUB_EFI_MAX_MEMORY_TYPE); - scanline_events = (struct grub_efiemu_mmap_scan *) -- grub_malloc (sizeof (struct grub_efiemu_mmap_scan) * 2 * mmap_num); -+ grub_calloc (mmap_num, sizeof (struct grub_efiemu_mmap_scan) * 2); - - /* Number of chunks can't increase more than by factor of 2 */ - result = (grub_efi_memory_descriptor_t *) -- grub_malloc (sizeof (grub_efi_memory_descriptor_t) * 2 * mmap_num); -+ grub_calloc (mmap_num, sizeof (grub_efi_memory_descriptor_t) * 2); - if (!result || !scanline_events) - { - grub_free (result); -@@ -660,7 +660,7 @@ grub_efiemu_mm_do_alloc (void) - - /* Preallocate mmap */ - efiemu_mmap = (grub_efi_memory_descriptor_t *) -- grub_malloc (mmap_reserved_size * sizeof (grub_efi_memory_descriptor_t)); -+ grub_calloc (mmap_reserved_size, sizeof (grub_efi_memory_descriptor_t)); - if (!efiemu_mmap) - { - grub_efiemu_unload (); -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 85a292557ac..8e118b315ce 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -293,8 +293,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct - font->num_chars = sect_length / FONT_CHAR_INDEX_ENTRY_SIZE; - - /* Allocate the character index array. */ -- font->char_index = grub_malloc (font->num_chars -- * sizeof (struct char_index_entry)); -+ font->char_index = grub_calloc (font->num_chars, sizeof (struct char_index_entry)); - if (!font->char_index) - return 1; - font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t)); -diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c -index 6b6a2bc9135..220b3712f2a 100644 ---- a/grub-core/fs/affs.c -+++ b/grub-core/fs/affs.c -@@ -301,7 +301,7 @@ grub_affs_read_symlink (grub_fshelp_node_t node) - return 0; - } - latin1[symlink_size] = 0; -- utf8 = grub_malloc (symlink_size * GRUB_MAX_UTF8_PER_LATIN1 + 1); -+ utf8 = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, symlink_size); - if (!utf8) - { - grub_free (latin1); -@@ -422,7 +422,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir, - return 1; - } - -- hashtable = grub_zalloc (data->htsize * sizeof (*hashtable)); -+ hashtable = grub_calloc (data->htsize, sizeof (*hashtable)); - if (!hashtable) - return 1; - -@@ -628,7 +628,7 @@ grub_affs_label (grub_device_t device, char **label) - len = file.namelen; - if (len > sizeof (file.name)) - len = sizeof (file.name); -- *label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1); -+ *label = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, len); - if (*label) - *grub_latin1_to_utf8 ((grub_uint8_t *) *label, file.name, len) = '\0'; - } -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 9cd7f4bdf65..ba080fdc580 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -442,7 +442,7 @@ lower_bound (struct grub_btrfs_data *data, - { - desc->allocated = 16; - desc->depth = 0; -- desc->data = grub_malloc (sizeof (desc->data[0]) * desc->allocated); -+ desc->data = grub_calloc (desc->allocated, sizeof (desc->data[0])); - if (!desc->data) - return grub_errno; - } -@@ -781,7 +781,7 @@ raid56_read_retry (struct grub_btrfs_data *data, - grub_err_t ret = GRUB_ERR_OUT_OF_MEMORY; - grub_uint64_t i, failed_devices; - -- buffers = grub_zalloc (sizeof(*buffers) * nstripes); -+ buffers = grub_calloc (nstripes, sizeof (*buffers)); - if (!buffers) - goto cleanup; - -@@ -2477,7 +2477,7 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), - *nsectors = 64 * 2 - 1; - if (*nsectors > max_nsectors) - *nsectors = max_nsectors; -- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); -+ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); - if (!*sectors) - return grub_errno; - for (i = 0; i < *nsectors; i++) -diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c -index ac0a40990e0..3fe842b4d8b 100644 ---- a/grub-core/fs/hfs.c -+++ b/grub-core/fs/hfs.c -@@ -1360,7 +1360,7 @@ grub_hfs_label (grub_device_t device, char **label) - grub_size_t len = data->sblock.volname[0]; - if (len > sizeof (data->sblock.volname) - 1) - len = sizeof (data->sblock.volname) - 1; -- *label = grub_malloc (len * MAX_UTF8_PER_MAC_ROMAN + 1); -+ *label = grub_calloc (MAX_UTF8_PER_MAC_ROMAN + 1, len); - if (*label) - macroman_to_utf8 (*label, data->sblock.volname + 1, - len + 1, 0); -diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c -index 54786bb1c6d..dae43becc97 100644 ---- a/grub-core/fs/hfsplus.c -+++ b/grub-core/fs/hfsplus.c -@@ -720,7 +720,7 @@ list_nodes (void *record, void *hook_arg) - if (! filename) - return 0; - -- keyname = grub_malloc (grub_be_to_cpu16 (catkey->namelen) * sizeof (*keyname)); -+ keyname = grub_calloc (grub_be_to_cpu16 (catkey->namelen), sizeof (*keyname)); - if (!keyname) - { - grub_free (filename); -@@ -1007,7 +1007,7 @@ grub_hfsplus_label (grub_device_t device, char **label) - grub_hfsplus_btree_recptr (&data->catalog_tree, node, ptr); - - label_len = grub_be_to_cpu16 (catkey->namelen); -- label_name = grub_malloc (label_len * sizeof (*label_name)); -+ label_name = grub_calloc (label_len, sizeof (*label_name)); - if (!label_name) - { - grub_free (node); -@@ -1029,7 +1029,7 @@ grub_hfsplus_label (grub_device_t device, char **label) - } - } - -- *label = grub_malloc (label_len * GRUB_MAX_UTF8_PER_UTF16 + 1); -+ *label = grub_calloc (label_len, GRUB_MAX_UTF8_PER_UTF16 + 1); - if (! *label) - { - grub_free (label_name); -diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c -index 49c0c632bf3..4f1b52a552a 100644 ---- a/grub-core/fs/iso9660.c -+++ b/grub-core/fs/iso9660.c -@@ -331,7 +331,7 @@ grub_iso9660_convert_string (grub_uint8_t *us, int len) - int i; - grub_uint16_t t[MAX_NAMELEN / 2 + 1]; - -- p = grub_malloc (len * GRUB_MAX_UTF8_PER_UTF16 + 1); -+ p = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1); - if (! p) - return NULL; - -diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c -index fc4e1f678d6..2f34f76da88 100644 ---- a/grub-core/fs/ntfs.c -+++ b/grub-core/fs/ntfs.c -@@ -556,8 +556,8 @@ get_utf8 (grub_uint8_t *in, grub_size_t len) - grub_uint16_t *tmp; - grub_size_t i; - -- buf = grub_malloc (len * GRUB_MAX_UTF8_PER_UTF16 + 1); -- tmp = grub_malloc (len * sizeof (tmp[0])); -+ buf = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1); -+ tmp = grub_calloc (len, sizeof (tmp[0])); - if (!buf || !tmp) - { - grub_free (buf); -diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c -index 50c1fe72f44..90f7fb37918 100644 ---- a/grub-core/fs/sfs.c -+++ b/grub-core/fs/sfs.c -@@ -266,7 +266,7 @@ grub_sfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - node->next_extent = node->block; - node->cache_size = 0; - -- node->cache = grub_malloc (sizeof (node->cache[0]) * cache_size); -+ node->cache = grub_calloc (cache_size, sizeof (node->cache[0])); - if (!node->cache) - { - grub_errno = 0; -diff --git a/grub-core/fs/tar.c b/grub-core/fs/tar.c -index 7d63e0c99c7..c551ed6b520 100644 ---- a/grub-core/fs/tar.c -+++ b/grub-core/fs/tar.c -@@ -120,7 +120,7 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name, - if (data->linkname_alloc < linksize + 1) - { - char *n; -- n = grub_malloc (2 * (linksize + 1)); -+ n = grub_calloc (2, linksize + 1); - if (!n) - return grub_errno; - grub_free (data->linkname); -diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c -index dc8b6e2d1c9..a83761674ad 100644 ---- a/grub-core/fs/udf.c -+++ b/grub-core/fs/udf.c -@@ -873,7 +873,7 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) - { - unsigned i; - utf16len = sz - 1; -- utf16 = grub_malloc (utf16len * sizeof (utf16[0])); -+ utf16 = grub_calloc (utf16len, sizeof (utf16[0])); - if (!utf16) - return NULL; - for (i = 0; i < utf16len; i++) -@@ -883,7 +883,7 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) - { - unsigned i; - utf16len = (sz - 1) / 2; -- utf16 = grub_malloc (utf16len * sizeof (utf16[0])); -+ utf16 = grub_calloc (utf16len, sizeof (utf16[0])); - if (!utf16) - return NULL; - for (i = 0; i < utf16len; i++) -diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c -index 2f72e42bf80..381dde556d1 100644 ---- a/grub-core/fs/zfs/zfs.c -+++ b/grub-core/fs/zfs/zfs.c -@@ -3325,7 +3325,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, - } - subvol->nkeys = 0; - zap_iterate (&keychain_dn, 8, count_zap_keys, &ctx, data); -- subvol->keyring = grub_zalloc (subvol->nkeys * sizeof (subvol->keyring[0])); -+ subvol->keyring = grub_calloc (subvol->nkeys, sizeof (subvol->keyring[0])); - if (!subvol->keyring) - { - grub_free (fsname); -@@ -4336,7 +4336,7 @@ grub_zfs_embed (grub_device_t device __attribute__ ((unused)), - *nsectors = (VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS); - if (*nsectors > max_nsectors) - *nsectors = max_nsectors; -- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); -+ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); - if (!*sectors) - return grub_errno; - for (i = 0; i < *nsectors; i++) -diff --git a/grub-core/gfxmenu/gui_string_util.c b/grub-core/gfxmenu/gui_string_util.c -index a9a415e3129..ba1e1eab319 100644 ---- a/grub-core/gfxmenu/gui_string_util.c -+++ b/grub-core/gfxmenu/gui_string_util.c -@@ -55,7 +55,7 @@ canonicalize_path (const char *path) - if (*p == '/') - components++; - -- char **path_array = grub_malloc (components * sizeof (*path_array)); -+ char **path_array = grub_calloc (components, sizeof (*path_array)); - if (! path_array) - return 0; - -diff --git a/grub-core/gfxmenu/widget-box.c b/grub-core/gfxmenu/widget-box.c -index b6060288914..470597ded2b 100644 ---- a/grub-core/gfxmenu/widget-box.c -+++ b/grub-core/gfxmenu/widget-box.c -@@ -303,10 +303,10 @@ grub_gfxmenu_create_box (const char *pixmaps_prefix, - box->content_height = 0; - box->raw_pixmaps = - (struct grub_video_bitmap **) -- grub_malloc (BOX_NUM_PIXMAPS * sizeof (struct grub_video_bitmap *)); -+ grub_calloc (BOX_NUM_PIXMAPS, sizeof (struct grub_video_bitmap *)); - box->scaled_pixmaps = - (struct grub_video_bitmap **) -- grub_malloc (BOX_NUM_PIXMAPS * sizeof (struct grub_video_bitmap *)); -+ grub_calloc (BOX_NUM_PIXMAPS, sizeof (struct grub_video_bitmap *)); - - /* Initialize all pixmap pointers to NULL so that proper destruction can - be performed if an error is encountered partway through construction. */ -diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c -index 6208a976363..43d98a7bdf4 100644 ---- a/grub-core/io/gzio.c -+++ b/grub-core/io/gzio.c -@@ -554,7 +554,7 @@ huft_build (unsigned *b, /* code lengths in bits (all assumed <= BMAX) */ - z = 1 << j; /* table entries for j-bit table */ - - /* allocate and link in new table */ -- q = (struct huft *) grub_zalloc ((z + 1) * sizeof (struct huft)); -+ q = (struct huft *) grub_calloc (z + 1, sizeof (struct huft)); - if (! q) - { - if (h) -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 279394d85eb..ab133fecce0 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -207,7 +207,7 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, - - len = grub_strlen (var); - len16 = len * GRUB_MAX_UTF16_PER_UTF8; -- var16 = grub_malloc ((len16 + 1) * sizeof (var16[0])); -+ var16 = grub_calloc (len16 + 1, sizeof (var16[0])); - if (!var16) - return grub_errno; - len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL); -@@ -245,7 +245,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - - len = grub_strlen (var); - len16 = len * GRUB_MAX_UTF16_PER_UTF8; -- var16 = grub_malloc ((len16 + 1) * sizeof (var16[0])); -+ var16 = grub_calloc (len16 + 1, sizeof (var16[0])); - if (!var16) - return NULL; - len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL); -@@ -401,7 +401,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) - while (len > 0 && fp->path_name[len - 1] == 0) - len--; - -- dup_name = grub_malloc (len * sizeof (*dup_name)); -+ dup_name = grub_calloc (len, sizeof (*dup_name)); - if (!dup_name) - { - grub_free (name); -diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c -index e9ec680cdbb..d975265b2e0 100644 ---- a/grub-core/kern/emu/hostdisk.c -+++ b/grub-core/kern/emu/hostdisk.c -@@ -615,7 +615,7 @@ static char * - grub_util_path_concat_real (size_t n, int ext, va_list ap) - { - size_t totlen = 0; -- char **l = xmalloc ((n + ext) * sizeof (l[0])); -+ char **l = xcalloc (n + ext, sizeof (l[0])); - char *r, *p, *pi; - size_t i; - int first = 1; -diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c -index 88d39360da0..fb30da9f404 100644 ---- a/grub-core/kern/fs.c -+++ b/grub-core/kern/fs.c -@@ -151,7 +151,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name) - while (p); - - /* Allocate a block list. */ -- blocks = grub_zalloc (sizeof (struct grub_fs_block) * (num + 1)); -+ blocks = grub_calloc (num + 1, sizeof (struct grub_fs_block)); - if (! blocks) - return 0; - -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 87afb43cd55..dc5e10b651a 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -750,7 +750,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, - args->ptr = args->prealloc; - else - { -- args->ptr = grub_malloc (args->count * sizeof (args->ptr[0])); -+ args->ptr = grub_calloc (args->count, sizeof (args->ptr[0])); - if (!args->ptr) - { - grub_errno = GRUB_ERR_NONE; -diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c -index 78175aac2d3..619db3122a0 100644 ---- a/grub-core/kern/parser.c -+++ b/grub-core/kern/parser.c -@@ -213,7 +213,7 @@ grub_parser_split_cmdline (const char *cmdline, - return grub_errno; - grub_memcpy (args, buffer, bp - buffer); - -- *argv = grub_malloc (sizeof (char *) * (*argc + 1)); -+ *argv = grub_calloc (*argc + 1, sizeof (char *)); - if (!*argv) - { - grub_free (args); -diff --git a/grub-core/kern/uboot/uboot.c b/grub-core/kern/uboot/uboot.c -index be4816fe6f5..aac8f9ae1fd 100644 ---- a/grub-core/kern/uboot/uboot.c -+++ b/grub-core/kern/uboot/uboot.c -@@ -133,7 +133,7 @@ grub_uboot_dev_enum (void) - return num_devices; - - max_devices = 2; -- enum_devices = grub_malloc (sizeof(struct device_info) * max_devices); -+ enum_devices = grub_calloc (max_devices, sizeof(struct device_info)); - if (!enum_devices) - return 0; - -diff --git a/grub-core/lib/libgcrypt/cipher/ac.c b/grub-core/lib/libgcrypt/cipher/ac.c -index f5e946a2d8f..63f6fcd11ef 100644 ---- a/grub-core/lib/libgcrypt/cipher/ac.c -+++ b/grub-core/lib/libgcrypt/cipher/ac.c -@@ -185,7 +185,7 @@ ac_data_mpi_copy (gcry_ac_mpi_t *data_mpis, unsigned int data_mpis_n, - gcry_mpi_t mpi; - char *label; - -- data_mpis_new = gcry_malloc (sizeof (*data_mpis_new) * data_mpis_n); -+ data_mpis_new = gcry_calloc (data_mpis_n, sizeof (*data_mpis_new)); - if (! data_mpis_new) - { - err = gcry_error_from_errno (errno); -@@ -572,7 +572,7 @@ _gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp, - } - - /* Add MPI list. */ -- arg_list = gcry_malloc (sizeof (*arg_list) * (data_n + 1)); -+ arg_list = gcry_calloc (data_n + 1, sizeof (*arg_list)); - if (! arg_list) - { - err = gcry_error_from_errno (errno); -@@ -1283,7 +1283,7 @@ ac_data_construct (const char *identifier, int include_flags, - /* We build a list of arguments to pass to - gcry_sexp_build_array(). */ - data_length = _gcry_ac_data_length (data); -- arg_list = gcry_malloc (sizeof (*arg_list) * (data_length * 2)); -+ arg_list = gcry_calloc (data_length, sizeof (*arg_list) * 2); - if (! arg_list) - { - err = gcry_error_from_errno (errno); -@@ -1593,7 +1593,7 @@ _gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits, - arg_list_n += 2; - - /* Allocate list. */ -- arg_list = gcry_malloc (sizeof (*arg_list) * arg_list_n); -+ arg_list = gcry_calloc (arg_list_n, sizeof (*arg_list)); - if (! arg_list) - { - err = gcry_error_from_errno (errno); -diff --git a/grub-core/lib/libgcrypt/cipher/primegen.c b/grub-core/lib/libgcrypt/cipher/primegen.c -index 2788e349fa9..b12e79b1922 100644 ---- a/grub-core/lib/libgcrypt/cipher/primegen.c -+++ b/grub-core/lib/libgcrypt/cipher/primegen.c -@@ -383,7 +383,7 @@ prime_generate_internal (int need_q_factor, - } - - /* Allocate an array to track pool usage. */ -- pool_in_use = gcry_malloc (n * sizeof *pool_in_use); -+ pool_in_use = gcry_calloc (n, sizeof *pool_in_use); - if (!pool_in_use) - { - err = gpg_err_code_from_errno (errno); -@@ -765,7 +765,7 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, - if (nbits < 16) - log_fatal ("can't generate a prime with less than %d bits\n", 16); - -- mods = gcry_xmalloc( no_of_small_prime_numbers * sizeof *mods ); -+ mods = gcry_xcalloc( no_of_small_prime_numbers, sizeof *mods); - /* Make nbits fit into gcry_mpi_t implementation. */ - val_2 = mpi_alloc_set_ui( 2 ); - val_3 = mpi_alloc_set_ui( 3); -diff --git a/grub-core/lib/libgcrypt/cipher/pubkey.c b/grub-core/lib/libgcrypt/cipher/pubkey.c -index 910982141e0..ca087ad75b9 100644 ---- a/grub-core/lib/libgcrypt/cipher/pubkey.c -+++ b/grub-core/lib/libgcrypt/cipher/pubkey.c -@@ -2941,7 +2941,7 @@ gcry_pk_encrypt (gcry_sexp_t *r_ciph, gcry_sexp_t s_data, gcry_sexp_t s_pkey) - * array to a format string, so we have to do it this way :-(. */ - /* FIXME: There is now such a format specifier, so we can - change the code to be more clear. */ -- arg_list = malloc (nelem * sizeof *arg_list); -+ arg_list = calloc (nelem, sizeof *arg_list); - if (!arg_list) - { - rc = gpg_err_code_from_syserror (); -@@ -3233,7 +3233,7 @@ gcry_pk_sign (gcry_sexp_t *r_sig, gcry_sexp_t s_hash, gcry_sexp_t s_skey) - } - strcpy (p, "))"); - -- arg_list = malloc (nelem * sizeof *arg_list); -+ arg_list = calloc (nelem, sizeof *arg_list); - if (!arg_list) - { - rc = gpg_err_code_from_syserror (); -diff --git a/grub-core/lib/priority_queue.c b/grub-core/lib/priority_queue.c -index 659be0b7f40..7d5e7c05aab 100644 ---- a/grub-core/lib/priority_queue.c -+++ b/grub-core/lib/priority_queue.c -@@ -92,7 +92,7 @@ grub_priority_queue_new (grub_size_t elsize, - { - struct grub_priority_queue *ret; - void *els; -- els = grub_malloc (elsize * 8); -+ els = grub_calloc (8, elsize); - if (!els) - return 0; - ret = (struct grub_priority_queue *) grub_malloc (sizeof (*ret)); -diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c -index 19c20085279..79037c093f7 100644 ---- a/grub-core/lib/reed_solomon.c -+++ b/grub-core/lib/reed_solomon.c -@@ -20,6 +20,7 @@ - #include - #include - #include -+#define xcalloc calloc - #define xmalloc malloc - #define grub_memset memset - #define grub_memcpy memcpy -@@ -158,11 +159,9 @@ rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs) - gf_single_t *rs_polynomial; - unsigned int i, j; - gf_single_t *m; -- m = xmalloc ((s + rs) * sizeof (gf_single_t)); -+ m = xcalloc (s + rs, sizeof (gf_single_t)); - grub_memcpy (m, data, s * sizeof (gf_single_t)); -- grub_memset (m + s, 0, rs * sizeof (gf_single_t)); -- rs_polynomial = xmalloc ((rs + 1) * sizeof (gf_single_t)); -- grub_memset (rs_polynomial, 0, (rs + 1) * sizeof (gf_single_t)); -+ rs_polynomial = xcalloc (rs + 1, sizeof (gf_single_t)); - rs_polynomial[rs] = 1; - /* Multiply with X - a^r */ - for (j = 0; j < rs; j++) -diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c -index ea3ebc719b1..5847aac3643 100644 ---- a/grub-core/lib/relocator.c -+++ b/grub-core/lib/relocator.c -@@ -495,9 +495,9 @@ malloc_in_range (struct grub_relocator *rel, - } - #endif - -- eventt = grub_malloc (maxevents * sizeof (events[0])); -+ eventt = grub_calloc (maxevents, sizeof (events[0])); - counter = grub_malloc ((DIGITSORT_MASK + 2) * sizeof (counter[0])); -- events = grub_malloc (maxevents * sizeof (events[0])); -+ events = grub_calloc (maxevents, sizeof (events[0])); - if (!events || !eventt || !counter) - { - grub_dprintf ("relocator", "events or counter allocation failed %d\n", -@@ -963,7 +963,7 @@ malloc_in_range (struct grub_relocator *rel, - #endif - unsigned cural = 0; - int oom = 0; -- res->subchunks = grub_malloc (sizeof (res->subchunks[0]) * nallocs); -+ res->subchunks = grub_calloc (nallocs, sizeof (res->subchunks[0])); - if (!res->subchunks) - oom = 1; - res->nsubchunks = nallocs; -@@ -1562,8 +1562,8 @@ grub_relocator_prepare_relocs (struct grub_relocator *rel, grub_addr_t addr, - count[(chunk->src & 0xff) + 1]++; - } - } -- from = grub_malloc (nchunks * sizeof (sorted[0])); -- to = grub_malloc (nchunks * sizeof (sorted[0])); -+ from = grub_calloc (nchunks, sizeof (sorted[0])); -+ to = grub_calloc (nchunks, sizeof (sorted[0])); - if (!from || !to) - { - grub_free (from); -diff --git a/grub-core/lib/zstd/fse_decompress.c b/grub-core/lib/zstd/fse_decompress.c -index 72bbead5bee..2227b84bc7e 100644 ---- a/grub-core/lib/zstd/fse_decompress.c -+++ b/grub-core/lib/zstd/fse_decompress.c -@@ -82,7 +82,7 @@ - FSE_DTable* FSE_createDTable (unsigned tableLog) - { - if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX; -- return (FSE_DTable*)malloc( FSE_DTABLE_SIZE_U32(tableLog) * sizeof (U32) ); -+ return (FSE_DTable*)calloc( FSE_DTABLE_SIZE_U32(tableLog), sizeof (U32) ); - } - - void FSE_freeDTable (FSE_DTable* dt) -diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c -index 51684914cfc..d70c174868e 100644 ---- a/grub-core/loader/arm/linux.c -+++ b/grub-core/loader/arm/linux.c -@@ -78,7 +78,7 @@ linux_prepare_atag (void *target_atag) - - /* some place for cmdline, initrd and terminator. */ - tmp_size = get_atag_size (atag_orig) + 20 + (arg_size) / 4; -- tmp_atag = grub_malloc (tmp_size * sizeof (grub_uint32_t)); -+ tmp_atag = grub_calloc (tmp_size, sizeof (grub_uint32_t)); - if (!tmp_atag) - return grub_errno; - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 2c529f71471..736505173cb 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -125,7 +125,7 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, - fp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE; - fp->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE; - -- path_name = grub_malloc (len * GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name)); -+ path_name = grub_calloc (len, GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name)); - if (!path_name) - return; - -diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c -index af6741d157c..a8d8bf7daed 100644 ---- a/grub-core/loader/i386/bsdXX.c -+++ b/grub-core/loader/i386/bsdXX.c -@@ -48,7 +48,7 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr) - if (e->e_ident[EI_CLASS] != SUFFIX (ELFCLASS)) - return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic")); - -- *shdr = grub_malloc ((grub_uint32_t) e->e_shnum * e->e_shentsize); -+ *shdr = grub_calloc (e->e_shnum, e->e_shentsize); - if (! *shdr) - return grub_errno; - -diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c -index e64ed08f580..b7d176b5d30 100644 ---- a/grub-core/loader/i386/xnu.c -+++ b/grub-core/loader/i386/xnu.c -@@ -295,7 +295,7 @@ grub_xnu_devprop_add_property_utf8 (struct grub_xnu_devprop_device_descriptor *d - return grub_errno; - - len = grub_strlen (name); -- utf16 = grub_malloc (sizeof (grub_uint16_t) * len); -+ utf16 = grub_calloc (len, sizeof (grub_uint16_t)); - if (!utf16) - { - grub_free (utf8); -@@ -331,7 +331,7 @@ grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor * - grub_uint16_t *utf16; - grub_err_t err; - -- utf16 = grub_malloc (sizeof (grub_uint16_t) * namelen); -+ utf16 = grub_calloc (namelen, sizeof (grub_uint16_t)); - if (!utf16) - return grub_errno; - grub_memcpy (utf16, name, sizeof (grub_uint16_t) * namelen); -diff --git a/grub-core/loader/macho.c b/grub-core/loader/macho.c -index 085f9c6890a..05710c48e06 100644 ---- a/grub-core/loader/macho.c -+++ b/grub-core/loader/macho.c -@@ -97,7 +97,7 @@ grub_macho_file (grub_file_t file, const char *filename, int is_64bit) - if (grub_file_seek (macho->file, sizeof (struct grub_macho_fat_header)) - == (grub_off_t) -1) - goto fail; -- archs = grub_malloc (sizeof (struct grub_macho_fat_arch) * narchs); -+ archs = grub_calloc (narchs, sizeof (struct grub_macho_fat_arch)); - if (!archs) - goto fail; - if (grub_file_read (macho->file, archs, -diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c -index 70cd1db513e..cc6853692a8 100644 ---- a/grub-core/loader/multiboot_elfxx.c -+++ b/grub-core/loader/multiboot_elfxx.c -@@ -217,7 +217,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - { - grub_uint8_t *shdr, *shdrptr; - -- shdr = grub_malloc ((grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize); -+ shdr = grub_calloc (ehdr->e_shnum, ehdr->e_shentsize); - if (!shdr) - return grub_errno; - -diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c -index e0f47e72b06..2f0ebd0b8bf 100644 ---- a/grub-core/loader/xnu.c -+++ b/grub-core/loader/xnu.c -@@ -801,7 +801,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), - if (grub_be_to_cpu32 (head.magic) == GRUB_MACHO_FAT_MAGIC) - { - narchs = grub_be_to_cpu32 (head.nfat_arch); -- archs = grub_malloc (sizeof (struct grub_macho_fat_arch) * narchs); -+ archs = grub_calloc (narchs, sizeof (struct grub_macho_fat_arch)); - if (! archs) - { - grub_file_close (file); -diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c -index b569cb23b5a..64684c23d0d 100644 ---- a/grub-core/mmap/mmap.c -+++ b/grub-core/mmap/mmap.c -@@ -143,9 +143,9 @@ grub_mmap_iterate (grub_memory_hook_t hook, void *hook_data) - - /* Initialize variables. */ - ctx.scanline_events = (struct grub_mmap_scan *) -- grub_malloc (sizeof (struct grub_mmap_scan) * 2 * mmap_num); -+ grub_calloc (mmap_num, sizeof (struct grub_mmap_scan) * 2); - -- present = grub_zalloc (sizeof (present[0]) * current_priority); -+ present = grub_calloc (current_priority, sizeof (present[0])); - - if (! ctx.scanline_events || !present) - { -diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 2e46842e829..5a5ebbfb1aa 100644 ---- a/grub-core/net/bootp.c -+++ b/grub-core/net/bootp.c -@@ -1629,7 +1629,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), - if (ncards == 0) - return grub_error (GRUB_ERR_NET_NO_CARD, N_("no network card found")); - -- ifaces = grub_zalloc (ncards * sizeof (ifaces[0])); -+ ifaces = grub_calloc (ncards, sizeof (ifaces[0])); - if (!ifaces) - return grub_errno; - -diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c -index 5d9afe093c0..e332d5eb4a4 100644 ---- a/grub-core/net/dns.c -+++ b/grub-core/net/dns.c -@@ -285,8 +285,8 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), - ptr++; - ptr += 4; - } -- *data->addresses = grub_malloc (sizeof ((*data->addresses)[0]) -- * grub_be_to_cpu16 (head->ancount)); -+ *data->addresses = grub_calloc (grub_be_to_cpu16 (head->ancount), -+ sizeof ((*data->addresses)[0])); - if (!*data->addresses) - { - grub_errno = GRUB_ERR_NONE; -@@ -406,8 +406,8 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), - dns_cache[h].addresses = 0; - dns_cache[h].name = grub_strdup (data->oname); - dns_cache[h].naddresses = *data->naddresses; -- dns_cache[h].addresses = grub_malloc (*data->naddresses -- * sizeof (dns_cache[h].addresses[0])); -+ dns_cache[h].addresses = grub_calloc (*data->naddresses, -+ sizeof (dns_cache[h].addresses[0])); - dns_cache[h].limit_time = grub_get_time_ms () + 1000 * ttl_all; - if (!dns_cache[h].addresses || !dns_cache[h].name) - { -@@ -479,7 +479,7 @@ grub_net_dns_lookup (const char *name, - } - } - -- sockets = grub_malloc (sizeof (sockets[0]) * n_servers); -+ sockets = grub_calloc (n_servers, sizeof (sockets[0])); - if (!sockets) - return grub_errno; - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 15073dde1c4..ad024c9ef7a 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -338,8 +338,8 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)), - ncards++; - } - -- ifaces = grub_zalloc (ncards * sizeof (ifaces[0])); -- slaacs = grub_zalloc (ncards * sizeof (slaacs[0])); -+ ifaces = grub_calloc (ncards, sizeof (ifaces[0])); -+ slaacs = grub_calloc (ncards, sizeof (slaacs[0])); - if (!ifaces || !slaacs) - { - grub_free (ifaces); -diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c -index b0ab47d73fd..d57fb72faa8 100644 ---- a/grub-core/normal/charset.c -+++ b/grub-core/normal/charset.c -@@ -203,7 +203,7 @@ grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, - { - grub_size_t msg_len = grub_strlen (msg); - -- *unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t)); -+ *unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t)); - - if (!*unicode_msg) - return -1; -@@ -488,7 +488,7 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen, - } - else - { -- n = grub_malloc (sizeof (n[0]) * (out->ncomb + 1)); -+ n = grub_calloc (out->ncomb + 1, sizeof (n[0])); - if (!n) - { - grub_errno = GRUB_ERR_NONE; -@@ -842,7 +842,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical, - } \ - } - -- visual = grub_malloc (sizeof (visual[0]) * logical_len); -+ visual = grub_calloc (logical_len, sizeof (visual[0])); - if (!visual) - return -1; - -@@ -1165,8 +1165,8 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical, - { - const grub_uint32_t *line_start = logical, *ptr; - struct grub_unicode_glyph *visual_ptr; -- *visual_out = visual_ptr = grub_malloc (3 * sizeof (visual_ptr[0]) -- * (logical_len + 2)); -+ *visual_out = visual_ptr = grub_calloc (logical_len + 2, -+ 3 * sizeof (visual_ptr[0])); - if (!visual_ptr) - return -1; - for (ptr = logical; ptr <= logical + logical_len; ptr++) -diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c -index c037d5050ed..c57242e2ea9 100644 ---- a/grub-core/normal/cmdline.c -+++ b/grub-core/normal/cmdline.c -@@ -41,7 +41,7 @@ grub_err_t - grub_set_history (int newsize) - { - grub_uint32_t **old_hist_lines = hist_lines; -- hist_lines = grub_malloc (sizeof (grub_uint32_t *) * newsize); -+ hist_lines = grub_calloc (newsize, sizeof (grub_uint32_t *)); - - /* Copy the old lines into the new buffer. */ - if (old_hist_lines) -@@ -114,7 +114,7 @@ static void - grub_history_set (int pos, grub_uint32_t *s, grub_size_t len) - { - grub_free (hist_lines[pos]); -- hist_lines[pos] = grub_malloc ((len + 1) * sizeof (grub_uint32_t)); -+ hist_lines[pos] = grub_calloc (len + 1, sizeof (grub_uint32_t)); - if (!hist_lines[pos]) - { - grub_print_error (); -@@ -349,7 +349,7 @@ grub_cmdline_get (const char *prompt_translated) - char *ret; - unsigned nterms; - -- buf = grub_malloc (max_len * sizeof (grub_uint32_t)); -+ buf = grub_calloc (max_len, sizeof (grub_uint32_t)); - if (!buf) - return 0; - -@@ -377,7 +377,7 @@ grub_cmdline_get (const char *prompt_translated) - FOR_ACTIVE_TERM_OUTPUTS(cur) - nterms++; - -- cl_terms = grub_malloc (sizeof (cl_terms[0]) * nterms); -+ cl_terms = grub_calloc (nterms, sizeof (cl_terms[0])); - if (!cl_terms) - { - grub_free (buf); -@@ -385,7 +385,7 @@ grub_cmdline_get (const char *prompt_translated) - } - cl_term_cur = cl_terms; - -- unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t)); -+ unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t)); - if (!unicode_msg) - { - grub_free (buf); -@@ -495,7 +495,7 @@ grub_cmdline_get (const char *prompt_translated) - grub_uint32_t *insert; - - insertlen = grub_strlen (insertu8); -- insert = grub_malloc ((insertlen + 1) * sizeof (grub_uint32_t)); -+ insert = grub_calloc (insertlen + 1, sizeof (grub_uint32_t)); - if (!insert) - { - grub_free (insertu8); -@@ -602,7 +602,7 @@ grub_cmdline_get (const char *prompt_translated) - - grub_free (kill_buf); - -- kill_buf = grub_malloc ((n + 1) * sizeof(grub_uint32_t)); -+ kill_buf = grub_calloc (n + 1, sizeof (grub_uint32_t)); - if (grub_errno) - { - grub_print_error (); -diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c -index 5785f67ee1c..f31487c1f58 100644 ---- a/grub-core/normal/menu_entry.c -+++ b/grub-core/normal/menu_entry.c -@@ -95,8 +95,8 @@ init_line (struct screen *screen, struct line *linep) - { - linep->len = 0; - linep->max_len = 80; -- linep->buf = grub_malloc ((linep->max_len + 1) * sizeof (linep->buf[0])); -- linep->pos = grub_zalloc (screen->nterms * sizeof (linep->pos[0])); -+ linep->buf = grub_calloc (linep->max_len + 1, sizeof (linep->buf[0])); -+ linep->pos = grub_calloc (screen->nterms, sizeof (linep->pos[0])); - if (! linep->buf || !linep->pos) - { - grub_free (linep->buf); -@@ -287,7 +287,7 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, - pos = linep->pos + (term_screen - screen->terms); - - if (!*pos) -- *pos = grub_zalloc ((linep->len + 1) * sizeof (**pos)); -+ *pos = grub_calloc (linep->len + 1, sizeof (**pos)); - - if (i == region_start || linep == screen->lines + screen->line - || (i > region_start && mode == ALL_LINES)) -@@ -471,7 +471,7 @@ insert_string (struct screen *screen, const char *s, int update) - - /* Insert the string. */ - current_linep = screen->lines + screen->line; -- unicode_msg = grub_malloc ((p - s) * sizeof (grub_uint32_t)); -+ unicode_msg = grub_calloc (p - s, sizeof (grub_uint32_t)); - - if (!unicode_msg) - return 0; -@@ -1023,7 +1023,7 @@ complete (struct screen *screen, int continuous, int update) - if (completion_buffer.buf) - { - buflen = grub_strlen (completion_buffer.buf); -- ucs4 = grub_malloc (sizeof (grub_uint32_t) * (buflen + 1)); -+ ucs4 = grub_calloc (buflen + 1, sizeof (grub_uint32_t)); - - if (!ucs4) - { -@@ -1265,7 +1265,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) - for (i = 0; i < (unsigned) screen->num_lines; i++) - { - grub_free (screen->lines[i].pos); -- screen->lines[i].pos = grub_zalloc (screen->nterms * sizeof (screen->lines[i].pos[0])); -+ screen->lines[i].pos = grub_calloc (screen->nterms, sizeof (screen->lines[i].pos[0])); - if (! screen->lines[i].pos) - { - grub_print_error (); -@@ -1275,7 +1275,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) - } - } - -- screen->terms = grub_zalloc (screen->nterms * sizeof (screen->terms[0])); -+ screen->terms = grub_calloc (screen->nterms, sizeof (screen->terms[0])); - if (!screen->terms) - { - grub_print_error (); -diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 7681f7d2893..ca135624356 100644 ---- a/grub-core/normal/menu_text.c -+++ b/grub-core/normal/menu_text.c -@@ -78,7 +78,7 @@ grub_print_message_indented_real (const char *msg, int margin_left, - grub_size_t msg_len = grub_strlen (msg) + 2; - int ret = 0; - -- unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t)); -+ unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t)); - - if (!unicode_msg) - return 0; -@@ -167,7 +167,7 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, - - title = entry ? entry->title : ""; - title_len = grub_strlen (title); -- unicode_title = grub_malloc (title_len * sizeof (*unicode_title)); -+ unicode_title = grub_calloc (title_len, sizeof (*unicode_title)); - if (! unicode_title) - /* XXX How to show this error? */ - return; -diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c -index a1e5c5a0daf..cc8c173b6e8 100644 ---- a/grub-core/normal/term.c -+++ b/grub-core/normal/term.c -@@ -264,7 +264,7 @@ grub_term_save_pos (void) - FOR_ACTIVE_TERM_OUTPUTS(cur) - cnt++; - -- ret = grub_malloc (cnt * sizeof (ret[0])); -+ ret = grub_calloc (cnt, sizeof (ret[0])); - if (!ret) - return NULL; - -@@ -1013,7 +1013,7 @@ grub_xnputs (const char *str, grub_size_t msg_len) - - grub_error_push (); - -- unicode_str = grub_malloc (msg_len * sizeof (grub_uint32_t)); -+ unicode_str = grub_calloc (msg_len, sizeof (grub_uint32_t)); - - grub_error_pop (); - -diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 36429a7cd25..f0c503f43d3 100644 ---- a/grub-core/osdep/linux/getroot.c -+++ b/grub-core/osdep/linux/getroot.c -@@ -176,7 +176,7 @@ grub_util_raid_getmembers (const char *name, int bootable) - if (ret != 0) - grub_util_error (_("ioctl GET_ARRAY_INFO error: %s"), strerror (errno)); - -- devicelist = xmalloc ((info.nr_disks + 1) * sizeof (char *)); -+ devicelist = xcalloc (info.nr_disks + 1, sizeof (char *)); - - for (i = 0, j = 0; j < info.nr_disks; i++) - { -@@ -249,7 +249,7 @@ grub_find_root_devices_from_btrfs (const char *dir) - return NULL; - } - -- ret = xmalloc ((fsi.num_devices + 1) * sizeof (ret[0])); -+ ret = xcalloc (fsi.num_devices + 1, sizeof (ret[0])); - - for (i = 1; i <= fsi.max_id && j < fsi.num_devices; i++) - { -@@ -508,7 +508,7 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) - if (relroot) - *relroot = NULL; - -- entries = xmalloc (entry_max * sizeof (*entries)); -+ entries = xcalloc (entry_max, sizeof (*entries)); - - again: - fp = grub_util_fopen ("/proc/self/mountinfo", "r"); -diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c -index b637c58efb7..46a881530c0 100644 ---- a/grub-core/osdep/unix/config.c -+++ b/grub-core/osdep/unix/config.c -@@ -102,7 +102,7 @@ grub_util_load_config (struct grub_util_config *cfg) - argv[0] = "sh"; - argv[1] = "-c"; - -- script = xmalloc (4 * strlen (cfgfile) + 300); -+ script = xcalloc (4, strlen (cfgfile) + 300); - - ptr = script; - memcpy (ptr, ". '", 3); -diff --git a/grub-core/osdep/windows/getroot.c b/grub-core/osdep/windows/getroot.c -index 661d9546192..eada663b261 100644 ---- a/grub-core/osdep/windows/getroot.c -+++ b/grub-core/osdep/windows/getroot.c -@@ -59,7 +59,7 @@ grub_get_mount_point (const TCHAR *path) - - for (ptr = path; *ptr; ptr++); - allocsize = (ptr - path + 10) * 2; -- out = xmalloc (allocsize * sizeof (out[0])); -+ out = xcalloc (allocsize, sizeof (out[0])); - - /* When pointing to EFI system partition GetVolumePathName fails - for ESP root and returns abberant information for everything -diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c -index 87a106c9b82..29cf42788fe 100644 ---- a/grub-core/osdep/windows/hostdisk.c -+++ b/grub-core/osdep/windows/hostdisk.c -@@ -111,7 +111,7 @@ grub_util_get_windows_path_real (const char *path) - - while (1) - { -- fpa = xmalloc (alloc * sizeof (fpa[0])); -+ fpa = xcalloc (alloc, sizeof (fpa[0])); - - len = GetFullPathName (tpath, alloc, fpa, NULL); - if (len >= alloc) -@@ -405,7 +405,7 @@ grub_util_fd_opendir (const char *name) - for (l = 0; name_windows[l]; l++); - for (l--; l >= 0 && (name_windows[l] == '\\' || name_windows[l] == '/'); l--); - l++; -- pattern = xmalloc ((l + 3) * sizeof (pattern[0])); -+ pattern = xcalloc (l + 3, sizeof (pattern[0])); - memcpy (pattern, name_windows, l * sizeof (pattern[0])); - pattern[l] = '\\'; - pattern[l + 1] = '*'; -diff --git a/grub-core/osdep/windows/init.c b/grub-core/osdep/windows/init.c -index e8ffd62c6a0..6297de6326a 100644 ---- a/grub-core/osdep/windows/init.c -+++ b/grub-core/osdep/windows/init.c -@@ -161,7 +161,7 @@ grub_util_host_init (int *argc __attribute__ ((unused)), - LPWSTR *targv; - - targv = CommandLineToArgvW (tcmdline, argc); -- *argv = xmalloc ((*argc + 1) * sizeof (argv[0])); -+ *argv = xcalloc (*argc + 1, sizeof (argv[0])); - - for (i = 0; i < *argc; i++) - (*argv)[i] = grub_util_tchar_to_utf8 (targv[i]); -diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c -index 7eb53fe01b4..1ef86bf5873 100644 ---- a/grub-core/osdep/windows/platform.c -+++ b/grub-core/osdep/windows/platform.c -@@ -225,8 +225,8 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, - grub_util_error ("%s", _("no EFI routines are available when running in BIOS mode")); - - distrib8_len = grub_strlen (efi_distributor); -- distributor16 = xmalloc ((distrib8_len + 1) * GRUB_MAX_UTF16_PER_UTF8 -- * sizeof (grub_uint16_t)); -+ distributor16 = xcalloc (distrib8_len + 1, -+ GRUB_MAX_UTF16_PER_UTF8 * sizeof (grub_uint16_t)); - distrib16_len = grub_utf8_to_utf16 (distributor16, distrib8_len * GRUB_MAX_UTF16_PER_UTF8, - (const grub_uint8_t *) efi_distributor, - distrib8_len, 0); -diff --git a/grub-core/osdep/windows/relpath.c b/grub-core/osdep/windows/relpath.c -index cb0861744ae..478e8ef14d5 100644 ---- a/grub-core/osdep/windows/relpath.c -+++ b/grub-core/osdep/windows/relpath.c -@@ -72,7 +72,7 @@ grub_make_system_path_relative_to_its_root (const char *path) - if (dirwindows[0] && dirwindows[1] == ':') - offset = 2; - } -- ret = xmalloc (sizeof (ret[0]) * (flen - offset + 2)); -+ ret = xcalloc (flen - offset + 2, sizeof (ret[0])); - if (dirwindows[offset] != '\\' - && dirwindows[offset] != '/' - && dirwindows[offset]) -diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c -index 103f6796f39..72a2e37cd48 100644 ---- a/grub-core/partmap/gpt.c -+++ b/grub-core/partmap/gpt.c -@@ -199,7 +199,7 @@ gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, - *nsectors = ctx.len; - if (*nsectors > max_nsectors) - *nsectors = max_nsectors; -- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); -+ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); - if (!*sectors) - return grub_errno; - for (i = 0; i < *nsectors; i++) -diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c -index 7b8e4507625..ee3f24982b8 100644 ---- a/grub-core/partmap/msdos.c -+++ b/grub-core/partmap/msdos.c -@@ -337,7 +337,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, - avail_nsectors = *nsectors; - if (*nsectors > max_nsectors) - *nsectors = max_nsectors; -- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); -+ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); - if (!*sectors) - return grub_errno; - for (i = 0; i < *nsectors; i++) -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index c6d2c365c9a..b55e171c931 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -587,7 +587,7 @@ gettext_append (struct grub_script_argv *result, const char *orig_str) - for (iptr = orig_str; *iptr; iptr++) - if (*iptr == '$') - dollar_cnt++; -- ctx.allowed_strings = grub_malloc (sizeof (ctx.allowed_strings[0]) * dollar_cnt); -+ ctx.allowed_strings = grub_calloc (dollar_cnt, sizeof (ctx.allowed_strings[0])); - - if (parse_string (orig_str, gettext_save_allow, &ctx, 0)) - goto fail; -diff --git a/grub-core/tests/fake_input.c b/grub-core/tests/fake_input.c -index 2d60852989c..b5eb516be2d 100644 ---- a/grub-core/tests/fake_input.c -+++ b/grub-core/tests/fake_input.c -@@ -49,7 +49,7 @@ grub_terminal_input_fake_sequence (int *seq_in, int nseq_in) - saved = grub_term_inputs; - if (seq) - grub_free (seq); -- seq = grub_malloc (nseq_in * sizeof (seq[0])); -+ seq = grub_calloc (nseq_in, sizeof (seq[0])); - if (!seq) - return; - -diff --git a/grub-core/tests/video_checksum.c b/grub-core/tests/video_checksum.c -index 74d5b65e5c7..44d0810698a 100644 ---- a/grub-core/tests/video_checksum.c -+++ b/grub-core/tests/video_checksum.c -@@ -336,7 +336,7 @@ grub_video_capture_write_bmp (const char *fname, - { - case 4: - { -- grub_uint8_t *buffer = xmalloc (mode_info->width * 3); -+ grub_uint8_t *buffer = xcalloc (3, mode_info->width); - grub_uint32_t rmask = ((1 << mode_info->red_mask_size) - 1); - grub_uint32_t gmask = ((1 << mode_info->green_mask_size) - 1); - grub_uint32_t bmask = ((1 << mode_info->blue_mask_size) - 1); -@@ -367,7 +367,7 @@ grub_video_capture_write_bmp (const char *fname, - } - case 3: - { -- grub_uint8_t *buffer = xmalloc (mode_info->width * 3); -+ grub_uint8_t *buffer = xcalloc (3, mode_info->width); - grub_uint32_t rmask = ((1 << mode_info->red_mask_size) - 1); - grub_uint32_t gmask = ((1 << mode_info->green_mask_size) - 1); - grub_uint32_t bmask = ((1 << mode_info->blue_mask_size) - 1); -@@ -407,7 +407,7 @@ grub_video_capture_write_bmp (const char *fname, - } - case 2: - { -- grub_uint8_t *buffer = xmalloc (mode_info->width * 3); -+ grub_uint8_t *buffer = xcalloc (3, mode_info->width); - grub_uint16_t rmask = ((1 << mode_info->red_mask_size) - 1); - grub_uint16_t gmask = ((1 << mode_info->green_mask_size) - 1); - grub_uint16_t bmask = ((1 << mode_info->blue_mask_size) - 1); -diff --git a/grub-core/video/capture.c b/grub-core/video/capture.c -index 4f83c744116..4d3195e017b 100644 ---- a/grub-core/video/capture.c -+++ b/grub-core/video/capture.c -@@ -89,7 +89,7 @@ grub_video_capture_start (const struct grub_video_mode_info *mode_info, - framebuffer.mode_info = *mode_info; - framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info); - -- framebuffer.ptr = grub_malloc (framebuffer.mode_info.height * framebuffer.mode_info.pitch); -+ framebuffer.ptr = grub_calloc (framebuffer.mode_info.height, framebuffer.mode_info.pitch); - if (!framebuffer.ptr) - return grub_errno; - -diff --git a/grub-core/video/emu/sdl.c b/grub-core/video/emu/sdl.c -index a2f639f66de..0ebab6f57dd 100644 ---- a/grub-core/video/emu/sdl.c -+++ b/grub-core/video/emu/sdl.c -@@ -172,7 +172,7 @@ grub_video_sdl_set_palette (unsigned int start, unsigned int count, - if (start + count > mode_info.number_of_colors) - count = mode_info.number_of_colors - start; - -- tmp = grub_malloc (count * sizeof (tmp[0])); -+ tmp = grub_calloc (count, sizeof (tmp[0])); - for (i = 0; i < count; i++) - { - tmp[i].r = palette_data[i].r; -diff --git a/grub-core/video/i386/pc/vga.c b/grub-core/video/i386/pc/vga.c -index 01f47112d37..b2f776c997b 100644 ---- a/grub-core/video/i386/pc/vga.c -+++ b/grub-core/video/i386/pc/vga.c -@@ -127,7 +127,7 @@ grub_video_vga_setup (unsigned int width, unsigned int height, - - vga_height = height ? : 480; - -- framebuffer.temporary_buffer = grub_malloc (vga_height * VGA_WIDTH); -+ framebuffer.temporary_buffer = grub_calloc (vga_height, VGA_WIDTH); - framebuffer.front_page = 0; - framebuffer.back_page = 0; - if (!framebuffer.temporary_buffer) -diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c -index 777e71334cb..61bd645379b 100644 ---- a/grub-core/video/readers/png.c -+++ b/grub-core/video/readers/png.c -@@ -309,7 +309,7 @@ grub_png_decode_image_header (struct grub_png_data *data) - if (data->is_16bit || data->is_gray || data->is_palette) - #endif - { -- data->image_data = grub_malloc (data->image_height * data->row_bytes); -+ data->image_data = grub_calloc (data->image_height, data->row_bytes); - if (grub_errno) - return grub_errno; - -diff --git a/util/getroot.c b/util/getroot.c -index fa3460d6cd8..6feb2a4de40 100644 ---- a/util/getroot.c -+++ b/util/getroot.c -@@ -219,7 +219,7 @@ make_device_name (const char *drive) - char *ret, *ptr; - const char *iptr; - -- ret = xmalloc (strlen (drive) * 2); -+ ret = xcalloc (2, strlen (drive)); - ptr = ret; - for (iptr = drive; *iptr; iptr++) - { -diff --git a/util/grub-file.c b/util/grub-file.c -index 50c18b6835a..b2e7dd69f4c 100644 ---- a/util/grub-file.c -+++ b/util/grub-file.c -@@ -54,7 +54,7 @@ main (int argc, char *argv[]) - - grub_util_host_init (&argc, &argv); - -- argv2 = xmalloc (argc * sizeof (argv2[0])); -+ argv2 = xcalloc (argc, sizeof (argv2[0])); - - if (argc == 2 && strcmp (argv[1], "--version") == 0) - { -diff --git a/util/grub-fstest.c b/util/grub-fstest.c -index 39bad1f432f..bfcef852d83 100644 ---- a/util/grub-fstest.c -+++ b/util/grub-fstest.c -@@ -650,7 +650,7 @@ argp_parser (int key, char *arg, struct argp_state *state) - if (args_count < num_disks) - { - if (args_count == 0) -- images = xmalloc (num_disks * sizeof (images[0])); -+ images = xcalloc (num_disks, sizeof (images[0])); - images[args_count] = grub_canonicalize_file_name (arg); - args_count++; - return 0; -@@ -734,7 +734,7 @@ main (int argc, char *argv[]) - - grub_util_host_init (&argc, &argv); - -- args = xmalloc (argc * sizeof (args[0])); -+ args = xcalloc (argc, sizeof (args[0])); - - argp_parse (&argp, argc, argv, 0, 0, 0); - -diff --git a/util/grub-install-common.c b/util/grub-install-common.c -index ca0ac612ac5..0295d40f5e4 100644 ---- a/util/grub-install-common.c -+++ b/util/grub-install-common.c -@@ -286,7 +286,7 @@ handle_install_list (struct install_list *il, const char *val, - il->n_entries++; - } - il->n_alloc = il->n_entries + 1; -- il->entries = xmalloc (il->n_alloc * sizeof (il->entries[0])); -+ il->entries = xcalloc (il->n_alloc, sizeof (il->entries[0])); - ptr = val; - for (ce = il->entries; ; ce++) - { -diff --git a/util/grub-install.c b/util/grub-install.c -index 8b6a037903e..dddb7576c97 100644 ---- a/util/grub-install.c -+++ b/util/grub-install.c -@@ -634,7 +634,7 @@ device_map_check_duplicates (const char *dev_map) - if (! fp) - return; - -- d = xmalloc (alloced * sizeof (d[0])); -+ d = xcalloc (alloced, sizeof (d[0])); - - while (fgets (buf, sizeof (buf), fp)) - { -@@ -1263,7 +1263,7 @@ main (int argc, char *argv[]) - ndev++; - } - -- grub_drives = xmalloc (sizeof (grub_drives[0]) * (ndev + 1)); -+ grub_drives = xcalloc (ndev + 1, sizeof (grub_drives[0])); - - for (curdev = grub_devices, curdrive = grub_drives; *curdev; curdev++, - curdrive++) -diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c -index d16ec63a16f..52bc9c848d9 100644 ---- a/util/grub-mkimagexx.c -+++ b/util/grub-mkimagexx.c -@@ -2294,10 +2294,8 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, - + grub_host_to_target16 (e->e_shstrndx) * smd.section_entsize); - smd.strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); - -- smd.addrs = xmalloc (sizeof (*smd.addrs) * smd.num_sections); -- memset (smd.addrs, 0, sizeof (*smd.addrs) * smd.num_sections); -- smd.vaddrs = xmalloc (sizeof (*smd.vaddrs) * smd.num_sections); -- memset (smd.vaddrs, 0, sizeof (*smd.vaddrs) * smd.num_sections); -+ smd.addrs = xcalloc (smd.num_sections, sizeof (*smd.addrs)); -+ smd.vaddrs = xcalloc (smd.num_sections, sizeof (*smd.vaddrs)); - - SUFFIX (locate_sections) (e, kernel_path, &smd, layout, image_target); - -diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c -index ce2cbc4f100..51831027f72 100644 ---- a/util/grub-mkrescue.c -+++ b/util/grub-mkrescue.c -@@ -441,8 +441,8 @@ main (int argc, char *argv[]) - xorriso = xstrdup ("xorriso"); - label_font = grub_util_path_concat (2, pkgdatadir, "unicode.pf2"); - -- argp_argv = xmalloc (sizeof (argp_argv[0]) * argc); -- xorriso_tail_argv = xmalloc (sizeof (argp_argv[0]) * argc); -+ argp_argv = xcalloc (argc, sizeof (argp_argv[0])); -+ xorriso_tail_argv = xcalloc (argc, sizeof (argp_argv[0])); - - xorriso_tail_argc = 0; - /* Program name */ -diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c -index 4907d44c0bd..edf309717c3 100644 ---- a/util/grub-mkstandalone.c -+++ b/util/grub-mkstandalone.c -@@ -296,7 +296,7 @@ main (int argc, char *argv[]) - grub_util_host_init (&argc, &argv); - grub_util_disable_fd_syncs (); - -- files = xmalloc ((argc + 1) * sizeof (files[0])); -+ files = xcalloc (argc + 1, sizeof (files[0])); - - argp_parse (&argp, argc, argv, 0, 0, 0); - -diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c -index 0d4084a108e..11331294f1b 100644 ---- a/util/grub-pe2elf.c -+++ b/util/grub-pe2elf.c -@@ -100,9 +100,9 @@ write_section_data (FILE* fp, const char *name, char *image, - char *pe_strtab = (image + pe_chdr->symtab_offset - + pe_chdr->num_symbols * sizeof (struct grub_pe32_symbol)); - -- section_map = xmalloc ((2 * pe_chdr->num_sections + 5) * sizeof (int)); -+ section_map = xcalloc (2 * pe_chdr->num_sections + 5, sizeof (int)); - section_map[0] = 0; -- shdr = xmalloc ((2 * pe_chdr->num_sections + 5) * sizeof (shdr[0])); -+ shdr = xcalloc (2 * pe_chdr->num_sections + 5, sizeof (shdr[0])); - idx = 1; - idx_reloc = pe_chdr->num_sections + 1; - -@@ -233,7 +233,7 @@ write_reloc_section (FILE* fp, const char *name, char *image, - - pe_sec = pe_shdr + shdr[i].sh_link; - pe_rel = (struct grub_pe32_reloc *) (image + pe_sec->relocations_offset); -- rel = (elf_reloc_t *) xmalloc (pe_sec->num_relocations * sizeof (elf_reloc_t)); -+ rel = (elf_reloc_t *) xcalloc (pe_sec->num_relocations, sizeof (elf_reloc_t)); - num_rels = 0; - modified = 0; - -@@ -365,12 +365,10 @@ write_symbol_table (FILE* fp, const char *name, char *image, - pe_symtab = (struct grub_pe32_symbol *) (image + pe_chdr->symtab_offset); - pe_strtab = (char *) (pe_symtab + pe_chdr->num_symbols); - -- symtab = (Elf_Sym *) xmalloc ((pe_chdr->num_symbols + 1) * -- sizeof (Elf_Sym)); -- memset (symtab, 0, (pe_chdr->num_symbols + 1) * sizeof (Elf_Sym)); -+ symtab = (Elf_Sym *) xcalloc (pe_chdr->num_symbols + 1, sizeof (Elf_Sym)); - num_syms = 1; - -- symtab_map = (int *) xmalloc (pe_chdr->num_symbols * sizeof (int)); -+ symtab_map = (int *) xcalloc (pe_chdr->num_symbols, sizeof (int)); - - for (i = 0; i < (int) pe_chdr->num_symbols; - i += pe_symtab->num_aux + 1, pe_symtab += pe_symtab->num_aux + 1) -diff --git a/util/grub-probe.c b/util/grub-probe.c -index 7481e487211..cf4291c00a4 100644 ---- a/util/grub-probe.c -+++ b/util/grub-probe.c -@@ -361,8 +361,8 @@ probe (const char *path, char **device_names, char delim) - grub_util_pull_device (*curdev); - ndev++; - } -- -- drives_names = xmalloc (sizeof (drives_names[0]) * (ndev + 1)); -+ -+ drives_names = xcalloc (ndev + 1, sizeof (drives_names[0])); - - for (curdev = device_names, curdrive = drives_names; *curdev; curdev++, - curdrive++) -diff --git a/include/grub/unicode.h b/include/grub/unicode.h -index a0403e91f9a..4de986a8576 100644 ---- a/include/grub/unicode.h -+++ b/include/grub/unicode.h -@@ -293,7 +293,7 @@ grub_unicode_glyph_dup (const struct grub_unicode_glyph *in) - grub_memcpy (out, in, sizeof (*in)); - if (in->ncomb > ARRAY_SIZE (out->combining_inline)) - { -- out->combining_ptr = grub_malloc (in->ncomb * sizeof (out->combining_ptr[0])); -+ out->combining_ptr = grub_calloc (in->ncomb, sizeof (out->combining_ptr[0])); - if (!out->combining_ptr) - { - grub_free (out); -@@ -315,7 +315,7 @@ grub_unicode_set_glyph (struct grub_unicode_glyph *out, - grub_memcpy (out, in, sizeof (*in)); - if (in->ncomb > ARRAY_SIZE (out->combining_inline)) - { -- out->combining_ptr = grub_malloc (in->ncomb * sizeof (out->combining_ptr[0])); -+ out->combining_ptr = grub_calloc (in->ncomb, sizeof (out->combining_ptr[0])); - if (!out->combining_ptr) - return; - grub_memcpy (out->combining_ptr, in->combining_ptr, diff --git a/0229-malloc-Use-overflow-checking-primitives-where-we-do-.patch b/0229-malloc-Use-overflow-checking-primitives-where-we-do-.patch deleted file mode 100644 index f840978..0000000 --- a/0229-malloc-Use-overflow-checking-primitives-where-we-do-.patch +++ /dev/null @@ -1,1320 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 15 Jun 2020 12:28:27 -0400 -Subject: [PATCH] malloc: Use overflow checking primitives where we do complex - allocations - -This attempts to fix the places where we do the following where -arithmetic_expr may include unvalidated data: - - X = grub_malloc(arithmetic_expr); - -It accomplishes this by doing the arithmetic ahead of time using grub_add(), -grub_sub(), grub_mul() and testing for overflow before proceeding. - -Among other issues, this fixes: - - allocation of integer overflow in grub_video_bitmap_create() - reported by Chris Coulson, - - allocation of integer overflow in grub_png_decode_image_header() - reported by Chris Coulson, - - allocation of integer overflow in grub_squash_read_symlink() - reported by Chris Coulson, - - allocation of integer overflow in grub_ext2_read_symlink() - reported by Chris Coulson, - - allocation of integer overflow in read_section_as_string() - reported by Chris Coulson. - -Fixes: CVE-2020-14309, CVE-2020-14310, CVE-2020-14311 - -Signed-off-by: Peter Jones -Reviewed-by: Daniel Kiper -Upstream-commit-id: 5fb2befbf04 ---- - grub-core/commands/legacycfg.c | 29 +++++++++++++++++++----- - grub-core/commands/wildcard.c | 36 ++++++++++++++++++++++++----- - grub-core/disk/ldm.c | 32 ++++++++++++++++++-------- - grub-core/font/font.c | 7 +++++- - grub-core/fs/btrfs.c | 28 +++++++++++++++-------- - grub-core/fs/ext2.c | 10 ++++++++- - grub-core/fs/iso9660.c | 51 +++++++++++++++++++++++++++++------------- - grub-core/fs/sfs.c | 27 +++++++++++++++++----- - grub-core/fs/squash4.c | 45 ++++++++++++++++++++++++++++--------- - grub-core/fs/udf.c | 41 +++++++++++++++++++++------------ - grub-core/fs/xfs.c | 11 +++++---- - grub-core/fs/zfs/zfs.c | 22 ++++++++++++------ - grub-core/fs/zfs/zfscrypt.c | 7 +++++- - grub-core/lib/arg.c | 20 +++++++++++++++-- - grub-core/loader/i386/bsd.c | 8 ++++++- - grub-core/net/dns.c | 9 +++++++- - grub-core/normal/charset.c | 10 +++++++-- - grub-core/normal/cmdline.c | 14 ++++++++++-- - grub-core/normal/menu_entry.c | 13 +++++++++-- - grub-core/script/argv.c | 16 +++++++++++-- - grub-core/script/lexer.c | 21 ++++++++++++++--- - grub-core/video/bitmap.c | 25 +++++++++++++-------- - grub-core/video/readers/png.c | 13 +++++++++-- - 23 files changed, 382 insertions(+), 113 deletions(-) - -diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c -index da5143d4360..782761c31aa 100644 ---- a/grub-core/commands/legacycfg.c -+++ b/grub-core/commands/legacycfg.c -@@ -32,6 +32,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -104,13 +105,22 @@ legacy_file (const char *filename) - if (newsuffix) - { - char *t; -- -+ grub_size_t sz; -+ -+ if (grub_add (grub_strlen (suffix), grub_strlen (newsuffix), &sz) || -+ grub_add (sz, 1, &sz)) -+ { -+ grub_errno = GRUB_ERR_OUT_OF_RANGE; -+ goto fail_0; -+ } -+ - t = suffix; -- suffix = grub_realloc (suffix, grub_strlen (suffix) -- + grub_strlen (newsuffix) + 1); -+ suffix = grub_realloc (suffix, sz); - if (!suffix) - { - grub_free (t); -+ -+ fail_0: - grub_free (entrysrc); - grub_free (parsed); - grub_free (newsuffix); -@@ -154,13 +164,22 @@ legacy_file (const char *filename) - else - { - char *t; -+ grub_size_t sz; -+ -+ if (grub_add (grub_strlen (entrysrc), grub_strlen (parsed), &sz) || -+ grub_add (sz, 1, &sz)) -+ { -+ grub_errno = GRUB_ERR_OUT_OF_RANGE; -+ goto fail_1; -+ } - - t = entrysrc; -- entrysrc = grub_realloc (entrysrc, grub_strlen (entrysrc) -- + grub_strlen (parsed) + 1); -+ entrysrc = grub_realloc (entrysrc, sz); - if (!entrysrc) - { - grub_free (t); -+ -+ fail_1: - grub_free (parsed); - grub_free (suffix); - return grub_errno; -diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c -index 560d437cdc6..8f67a4be7f0 100644 ---- a/grub-core/commands/wildcard.c -+++ b/grub-core/commands/wildcard.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - #include - -@@ -48,6 +49,7 @@ merge (char **dest, char **ps) - int i; - int j; - char **p; -+ grub_size_t sz; - - if (! dest) - return ps; -@@ -60,7 +62,12 @@ merge (char **dest, char **ps) - for (j = 0; ps[j]; j++) - ; - -- p = grub_realloc (dest, sizeof (char*) * (i + j + 1)); -+ if (grub_add (i, j, &sz) || -+ grub_add (sz, 1, &sz) || -+ grub_mul (sz, sizeof (char *), &sz)) -+ return dest; -+ -+ p = grub_realloc (dest, sz); - if (! p) - { - grub_free (dest); -@@ -115,8 +122,15 @@ make_regex (const char *start, const char *end, regex_t *regexp) - char ch; - int i = 0; - unsigned len = end - start; -- char *buffer = grub_malloc (len * 2 + 2 + 1); /* worst case size. */ -+ char *buffer; -+ grub_size_t sz; - -+ /* Worst case size is (len * 2 + 2 + 1). */ -+ if (grub_mul (len, 2, &sz) || -+ grub_add (sz, 3, &sz)) -+ return 1; -+ -+ buffer = grub_malloc (sz); - if (! buffer) - return 1; - -@@ -226,6 +240,7 @@ match_devices_iter (const char *name, void *data) - struct match_devices_ctx *ctx = data; - char **t; - char *buffer; -+ grub_size_t sz; - - /* skip partitions if asked to. */ - if (ctx->noparts && grub_strchr (name, ',')) -@@ -239,11 +254,16 @@ match_devices_iter (const char *name, void *data) - if (regexec (ctx->regexp, buffer, 0, 0, 0)) - { - grub_dprintf ("expand", "not matched\n"); -+ fail: - grub_free (buffer); - return 0; - } - -- t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2)); -+ if (grub_add (ctx->ndev, 2, &sz) || -+ grub_mul (sz, sizeof (char *), &sz)) -+ goto fail; -+ -+ t = grub_realloc (ctx->devs, sz); - if (! t) - { - grub_free (buffer); -@@ -300,6 +320,7 @@ match_files_iter (const char *name, - struct match_files_ctx *ctx = data; - char **t; - char *buffer; -+ grub_size_t sz; - - /* skip . and .. names */ - if (grub_strcmp(".", name) == 0 || grub_strcmp("..", name) == 0) -@@ -315,9 +336,14 @@ match_files_iter (const char *name, - if (! buffer) - return 1; - -- t = grub_realloc (ctx->files, sizeof (char*) * (ctx->nfile + 2)); -- if (! t) -+ if (grub_add (ctx->nfile, 2, &sz) || -+ grub_mul (sz, sizeof (char *), &sz)) -+ goto fail; -+ -+ t = grub_realloc (ctx->files, sz); -+ if (!t) - { -+ fail: - grub_free (buffer); - return 1; - } -diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c -index e6323701ab3..58f8a53e1ab 100644 ---- a/grub-core/disk/ldm.c -+++ b/grub-core/disk/ldm.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - - #ifdef GRUB_UTIL - #include -@@ -289,6 +290,7 @@ make_vg (grub_disk_t disk, - struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE - / sizeof (struct grub_ldm_vblk)]; - unsigned i; -+ grub_size_t sz; - err = grub_disk_read (disk, cursec, 0, - sizeof(vblk), &vblk); - if (err) -@@ -350,7 +352,13 @@ make_vg (grub_disk_t disk, - grub_free (lv); - goto fail2; - } -- lv->name = grub_malloc (*ptr + 1); -+ if (grub_add (*ptr, 1, &sz)) -+ { -+ grub_free (lv->internal_id); -+ grub_free (lv); -+ goto fail2; -+ } -+ lv->name = grub_malloc (sz); - if (!lv->name) - { - grub_free (lv->internal_id); -@@ -599,10 +607,13 @@ make_vg (grub_disk_t disk, - if (lv->segments->node_alloc == lv->segments->node_count) - { - void *t; -- lv->segments->node_alloc *= 2; -- t = grub_realloc (lv->segments->nodes, -- sizeof (*lv->segments->nodes) -- * lv->segments->node_alloc); -+ grub_size_t sz; -+ -+ if (grub_mul (lv->segments->node_alloc, 2, &lv->segments->node_alloc) || -+ grub_mul (lv->segments->node_alloc, sizeof (*lv->segments->nodes), &sz)) -+ goto fail2; -+ -+ t = grub_realloc (lv->segments->nodes, sz); - if (!t) - goto fail2; - lv->segments->nodes = t; -@@ -723,10 +734,13 @@ make_vg (grub_disk_t disk, - if (comp->segment_alloc == comp->segment_count) - { - void *t; -- comp->segment_alloc *= 2; -- t = grub_realloc (comp->segments, -- comp->segment_alloc -- * sizeof (*comp->segments)); -+ grub_size_t sz; -+ -+ if (grub_mul (comp->segment_alloc, 2, &comp->segment_alloc) || -+ grub_mul (comp->segment_alloc, sizeof (*comp->segments), &sz)) -+ goto fail2; -+ -+ t = grub_realloc (comp->segments, sz); - if (!t) - goto fail2; - comp->segments = t; -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 8e118b315ce..5edb477ac2e 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -30,6 +30,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -360,9 +361,13 @@ static char * - read_section_as_string (struct font_file_section *section) - { - char *str; -+ grub_size_t sz; - grub_ssize_t ret; - -- str = grub_malloc (section->length + 1); -+ if (grub_add (section->length, 1, &sz)) -+ return NULL; -+ -+ str = grub_malloc (sz); - if (!str) - return 0; - -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index ba080fdc580..0d8c666aea1 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -44,6 +44,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -358,9 +359,13 @@ save_ref (struct grub_btrfs_leaf_descriptor *desc, - if (desc->allocated < desc->depth) - { - void *newdata; -- desc->allocated *= 2; -- newdata = grub_realloc (desc->data, sizeof (desc->data[0]) -- * desc->allocated); -+ grub_size_t sz; -+ -+ if (grub_mul (desc->allocated, 2, &desc->allocated) || -+ grub_mul (desc->allocated, sizeof (desc->data[0]), &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ -+ newdata = grub_realloc (desc->data, sz); - if (!newdata) - return grub_errno; - desc->data = newdata; -@@ -651,16 +656,21 @@ find_device (struct grub_btrfs_data *data, grub_uint64_t id) - if (data->n_devices_attached > data->n_devices_allocated) - { - void *tmp; -- data->n_devices_allocated = 2 * data->n_devices_attached + 1; -- data->devices_attached -- = grub_realloc (tmp = data->devices_attached, -- data->n_devices_allocated -- * sizeof (data->devices_attached[0])); -+ grub_size_t sz; -+ -+ if (grub_mul (data->n_devices_attached, 2, &data->n_devices_allocated) || -+ grub_add (data->n_devices_allocated, 1, &data->n_devices_allocated) || -+ grub_mul (data->n_devices_allocated, sizeof (data->devices_attached[0]), &sz)) -+ goto fail; -+ -+ data->devices_attached = grub_realloc (tmp = data->devices_attached, sz); - if (!data->devices_attached) - { -+ data->devices_attached = tmp; -+ -+ fail: - if (ctx.dev_found) - grub_device_close (ctx.dev_found); -- data->devices_attached = tmp; - return NULL; - } - } -diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c -index 9b389802a35..ac33bcd68c4 100644 ---- a/grub-core/fs/ext2.c -+++ b/grub-core/fs/ext2.c -@@ -46,6 +46,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -703,6 +704,7 @@ grub_ext2_read_symlink (grub_fshelp_node_t node) - { - char *symlink; - struct grub_fshelp_node *diro = node; -+ grub_size_t sz; - - if (! diro->inode_read) - { -@@ -717,7 +719,13 @@ grub_ext2_read_symlink (grub_fshelp_node_t node) - } - } - -- symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1); -+ if (grub_add (grub_le_to_cpu32 (diro->inode.size), 1, &sz)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ return NULL; -+ } -+ -+ symlink = grub_malloc (sz); - if (! symlink) - return 0; - -diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c -index 4f1b52a552a..7ba5b300bc1 100644 ---- a/grub-core/fs/iso9660.c -+++ b/grub-core/fs/iso9660.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -531,8 +532,13 @@ add_part (struct iterate_dir_ctx *ctx, - int len2) - { - int size = ctx->symlink ? grub_strlen (ctx->symlink) : 0; -+ grub_size_t sz; - -- ctx->symlink = grub_realloc (ctx->symlink, size + len2 + 1); -+ if (grub_add (size, len2, &sz) || -+ grub_add (sz, 1, &sz)) -+ return; -+ -+ ctx->symlink = grub_realloc (ctx->symlink, sz); - if (! ctx->symlink) - return; - -@@ -560,17 +566,24 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, - { - grub_size_t off = 0, csize = 1; - char *old; -+ grub_size_t sz; -+ - csize = entry->len - 5; - old = ctx->filename; - if (ctx->filename_alloc) - { - off = grub_strlen (ctx->filename); -- ctx->filename = grub_realloc (ctx->filename, csize + off + 1); -+ if (grub_add (csize, off, &sz) || -+ grub_add (sz, 1, &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ ctx->filename = grub_realloc (ctx->filename, sz); - } - else - { - off = 0; -- ctx->filename = grub_zalloc (csize + 1); -+ if (grub_add (csize, 1, &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ ctx->filename = grub_zalloc (sz); - } - if (!ctx->filename) - { -@@ -776,14 +789,18 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, - if (node->have_dirents >= node->alloc_dirents) - { - struct grub_fshelp_node *new_node; -- node->alloc_dirents *= 2; -- new_node = grub_realloc (node, -- sizeof (struct grub_fshelp_node) -- + ((node->alloc_dirents -- - ARRAY_SIZE (node->dirents)) -- * sizeof (node->dirents[0]))); -+ grub_size_t sz; -+ -+ if (grub_mul (node->alloc_dirents, 2, &node->alloc_dirents) || -+ grub_sub (node->alloc_dirents, ARRAY_SIZE (node->dirents), &sz) || -+ grub_mul (sz, sizeof (node->dirents[0]), &sz) || -+ grub_add (sz, sizeof (struct grub_fshelp_node), &sz)) -+ goto fail_0; -+ -+ new_node = grub_realloc (node, sz); - if (!new_node) - { -+ fail_0: - if (ctx.filename_alloc) - grub_free (ctx.filename); - grub_free (node); -@@ -799,14 +816,18 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, - * sizeof (node->dirents[0]) < grub_strlen (ctx.symlink) + 1) - { - struct grub_fshelp_node *new_node; -- new_node = grub_realloc (node, -- sizeof (struct grub_fshelp_node) -- + ((node->alloc_dirents -- - ARRAY_SIZE (node->dirents)) -- * sizeof (node->dirents[0])) -- + grub_strlen (ctx.symlink) + 1); -+ grub_size_t sz; -+ -+ if (grub_sub (node->alloc_dirents, ARRAY_SIZE (node->dirents), &sz) || -+ grub_mul (sz, sizeof (node->dirents[0]), &sz) || -+ grub_add (sz, sizeof (struct grub_fshelp_node) + 1, &sz) || -+ grub_add (sz, grub_strlen (ctx.symlink), &sz)) -+ goto fail_1; -+ -+ new_node = grub_realloc (node, sz); - if (!new_node) - { -+ fail_1: - if (ctx.filename_alloc) - grub_free (ctx.filename); - grub_free (node); -diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c -index 90f7fb37918..de2b107a4a4 100644 ---- a/grub-core/fs/sfs.c -+++ b/grub-core/fs/sfs.c -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -307,10 +308,15 @@ grub_sfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - if (node->cache && node->cache_size >= node->cache_allocated) - { - struct cache_entry *e = node->cache; -- e = grub_realloc (node->cache,node->cache_allocated * 2 -- * sizeof (e[0])); -+ grub_size_t sz; -+ -+ if (grub_mul (node->cache_allocated, 2 * sizeof (e[0]), &sz)) -+ goto fail; -+ -+ e = grub_realloc (node->cache, sz); - if (!e) - { -+ fail: - grub_errno = 0; - grub_free (node->cache); - node->cache = 0; -@@ -477,10 +483,16 @@ grub_sfs_create_node (struct grub_fshelp_node **node, - grub_size_t len = grub_strlen (name); - grub_uint8_t *name_u8; - int ret; -+ grub_size_t sz; -+ -+ if (grub_mul (len, GRUB_MAX_UTF8_PER_LATIN1, &sz) || -+ grub_add (sz, 1, &sz)) -+ return 1; -+ - *node = grub_malloc (sizeof (**node)); - if (!*node) - return 1; -- name_u8 = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1); -+ name_u8 = grub_malloc (sz); - if (!name_u8) - { - grub_free (*node); -@@ -724,8 +736,13 @@ grub_sfs_label (grub_device_t device, char **label) - data = grub_sfs_mount (disk); - if (data) - { -- grub_size_t len = grub_strlen (data->label); -- *label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1); -+ grub_size_t sz, len = grub_strlen (data->label); -+ -+ if (grub_mul (len, GRUB_MAX_UTF8_PER_LATIN1, &sz) || -+ grub_add (sz, 1, &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ -+ *label = grub_malloc (sz); - if (*label) - *grub_latin1_to_utf8 ((grub_uint8_t *) *label, - (const grub_uint8_t *) data->label, -diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c -index 95d5c1e1ff4..785123894e3 100644 ---- a/grub-core/fs/squash4.c -+++ b/grub-core/fs/squash4.c -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - #include - - #include "xz.h" -@@ -459,7 +460,17 @@ grub_squash_read_symlink (grub_fshelp_node_t node) - { - char *ret; - grub_err_t err; -- ret = grub_malloc (grub_le_to_cpu32 (node->ino.symlink.namelen) + 1); -+ grub_size_t sz; -+ -+ if (grub_add (grub_le_to_cpu32 (node->ino.symlink.namelen), 1, &sz)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ return NULL; -+ } -+ -+ ret = grub_malloc (sz); -+ if (!ret) -+ return NULL; - - err = read_chunk (node->data, ret, - grub_le_to_cpu32 (node->ino.symlink.namelen), -@@ -506,11 +517,16 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir, - - { - grub_fshelp_node_t node; -- node = grub_malloc (sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); -+ grub_size_t sz; -+ -+ if (grub_mul (dir->stsize, sizeof (dir->stack[0]), &sz) || -+ grub_add (sz, sizeof (*node), &sz)) -+ return 0; -+ -+ node = grub_malloc (sz); - if (!node) - return 0; -- grub_memcpy (node, dir, -- sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); -+ grub_memcpy (node, dir, sz); - if (hook (".", GRUB_FSHELP_DIR, node, hook_data)) - return 1; - -@@ -518,12 +534,15 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir, - { - grub_err_t err; - -- node = grub_malloc (sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); -+ if (grub_mul (dir->stsize, sizeof (dir->stack[0]), &sz) || -+ grub_add (sz, sizeof (*node), &sz)) -+ return 0; -+ -+ node = grub_malloc (sz); - if (!node) - return 0; - -- grub_memcpy (node, dir, -- sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); -+ grub_memcpy (node, dir, sz); - - node->stsize--; - err = read_chunk (dir->data, &node->ino, sizeof (node->ino), -@@ -557,6 +576,7 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir, - enum grub_fshelp_filetype filetype = GRUB_FSHELP_REG; - struct grub_squash_dirent di; - struct grub_squash_inode ino; -+ grub_size_t sz; - - err = read_chunk (dir->data, &di, sizeof (di), - grub_le_to_cpu64 (dir->data->sb.diroffset) -@@ -589,13 +609,16 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir, - if (grub_le_to_cpu16 (di.type) == SQUASH_TYPE_SYMLINK) - filetype = GRUB_FSHELP_SYMLINK; - -- node = grub_malloc (sizeof (*node) -- + (dir->stsize + 1) * sizeof (dir->stack[0])); -+ if (grub_add (dir->stsize, 1, &sz) || -+ grub_mul (sz, sizeof (dir->stack[0]), &sz) || -+ grub_add (sz, sizeof (*node), &sz)) -+ return 0; -+ -+ node = grub_malloc (sz); - if (! node) - return 0; - -- grub_memcpy (node, dir, -- sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); -+ grub_memcpy (node, dir, sz - sizeof(dir->stack[0])); - - node->ino = ino; - node->stack[node->stsize].ino_chunk = grub_le_to_cpu32 (dh.ino_chunk); -diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c -index a83761674ad..21ac7f4460d 100644 ---- a/grub-core/fs/udf.c -+++ b/grub-core/fs/udf.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -890,9 +891,19 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) - utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2]; - } - if (!outbuf) -- outbuf = grub_malloc (utf16len * GRUB_MAX_UTF8_PER_UTF16 + 1); -+ { -+ grub_size_t size; -+ -+ if (grub_mul (utf16len, GRUB_MAX_UTF8_PER_UTF16, &size) || -+ grub_add (size, 1, &size)) -+ goto fail; -+ -+ outbuf = grub_malloc (size); -+ } - if (outbuf) - *grub_utf16_to_utf8 ((grub_uint8_t *) outbuf, utf16, utf16len) = '\0'; -+ -+ fail: - grub_free (utf16); - return outbuf; - } -@@ -1005,7 +1016,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node) - grub_size_t sz = U64 (node->block.fe.file_size); - grub_uint8_t *raw; - const grub_uint8_t *ptr; -- char *out, *optr; -+ char *out = NULL, *optr; - - if (sz < 4) - return NULL; -@@ -1013,14 +1024,16 @@ grub_udf_read_symlink (grub_fshelp_node_t node) - if (!raw) - return NULL; - if (grub_udf_read_file (node, NULL, NULL, 0, sz, (char *) raw) < 0) -- { -- grub_free (raw); -- return NULL; -- } -+ goto fail_1; - -- out = grub_malloc (sz * 2 + 1); -+ if (grub_mul (sz, 2, &sz) || -+ grub_add (sz, 1, &sz)) -+ goto fail_0; -+ -+ out = grub_malloc (sz); - if (!out) - { -+ fail_0: - grub_free (raw); - return NULL; - } -@@ -1031,17 +1044,17 @@ grub_udf_read_symlink (grub_fshelp_node_t node) - { - grub_size_t s; - if ((grub_size_t) (ptr - raw + 4) > sz) -- goto fail; -+ goto fail_1; - if (!(ptr[2] == 0 && ptr[3] == 0)) -- goto fail; -+ goto fail_1; - s = 4 + ptr[1]; - if ((grub_size_t) (ptr - raw + s) > sz) -- goto fail; -+ goto fail_1; - switch (*ptr) - { - case 1: - if (ptr[1]) -- goto fail; -+ goto fail_1; - /* Fallthrough. */ - case 2: - /* in 4 bytes. out: 1 byte. */ -@@ -1066,11 +1079,11 @@ grub_udf_read_symlink (grub_fshelp_node_t node) - if (optr != out) - *optr++ = '/'; - if (!read_string (ptr + 4, s - 4, optr)) -- goto fail; -+ goto fail_1; - optr += grub_strlen (optr); - break; - default: -- goto fail; -+ goto fail_1; - } - ptr += s; - } -@@ -1078,7 +1091,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node) - grub_free (raw); - return out; - -- fail: -+ fail_1: - grub_free (raw); - grub_free (out); - grub_error (GRUB_ERR_BAD_FS, "invalid symlink"); -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index 96ffecbfc92..ea6590290b1 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -899,6 +900,7 @@ static struct grub_xfs_data * - grub_xfs_mount (grub_disk_t disk) - { - struct grub_xfs_data *data = 0; -+ grub_size_t sz; - - data = grub_zalloc (sizeof (struct grub_xfs_data)); - if (!data) -@@ -913,10 +915,11 @@ grub_xfs_mount (grub_disk_t disk) - if (!grub_xfs_sb_valid(data)) - goto fail; - -- data = grub_realloc (data, -- sizeof (struct grub_xfs_data) -- - sizeof (struct grub_xfs_inode) -- + grub_xfs_inode_size(data) + 1); -+ if (grub_add (grub_xfs_inode_size (data), -+ sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) + 1, &sz)) -+ goto fail; -+ -+ data = grub_realloc (data, sz); - - if (! data) - goto fail; -diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c -index 381dde556d1..36d0373a6a5 100644 ---- a/grub-core/fs/zfs/zfs.c -+++ b/grub-core/fs/zfs/zfs.c -@@ -55,6 +55,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -773,11 +774,14 @@ fill_vdev_info (struct grub_zfs_data *data, - if (data->n_devices_attached > data->n_devices_allocated) - { - void *tmp; -- data->n_devices_allocated = 2 * data->n_devices_attached + 1; -- data->devices_attached -- = grub_realloc (tmp = data->devices_attached, -- data->n_devices_allocated -- * sizeof (data->devices_attached[0])); -+ grub_size_t sz; -+ -+ if (grub_mul (data->n_devices_attached, 2, &data->n_devices_allocated) || -+ grub_add (data->n_devices_allocated, 1, &data->n_devices_allocated) || -+ grub_mul (data->n_devices_allocated, sizeof (data->devices_attached[0]), &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ -+ data->devices_attached = grub_realloc (tmp = data->devices_attached, sz); - if (!data->devices_attached) - { - data->devices_attached = tmp; -@@ -3468,14 +3472,18 @@ grub_zfs_nvlist_lookup_nvlist (const char *nvlist, const char *name) - { - char *nvpair; - char *ret; -- grub_size_t size; -+ grub_size_t size, sz; - int found; - - found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair, - &size, 0); - if (!found) - return 0; -- ret = grub_zalloc (size + 3 * sizeof (grub_uint32_t)); -+ -+ if (grub_add (size, 3 * sizeof (grub_uint32_t), &sz)) -+ return 0; -+ -+ ret = grub_zalloc (sz); - if (!ret) - return 0; - grub_memcpy (ret, nvlist, sizeof (grub_uint32_t)); -diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c -index 1402e0bc29b..de3b015f582 100644 ---- a/grub-core/fs/zfs/zfscrypt.c -+++ b/grub-core/fs/zfs/zfscrypt.c -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -82,9 +83,13 @@ grub_zfs_add_key (grub_uint8_t *key_in, - int passphrase) - { - struct grub_zfs_wrap_key *key; -+ grub_size_t sz; -+ - if (!passphrase && keylen > 32) - keylen = 32; -- key = grub_malloc (sizeof (*key) + keylen); -+ if (grub_add (sizeof (*key), keylen, &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ key = grub_malloc (sz); - if (!key) - return grub_errno; - key->is_passphrase = passphrase; -diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c -index ccc185017ee..8439a0062ff 100644 ---- a/grub-core/lib/arg.c -+++ b/grub-core/lib/arg.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - /* Built-in parser for default options. */ - static const struct grub_arg_option help_options[] = -@@ -216,7 +217,13 @@ static inline grub_err_t - add_arg (char ***argl, int *num, char *s) - { - char **p = *argl; -- *argl = grub_realloc (*argl, (++(*num) + 1) * sizeof (char *)); -+ grub_size_t sz; -+ -+ if (grub_add (++(*num), 1, &sz) || -+ grub_mul (sz, sizeof (char *), &sz)) -+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ -+ *argl = grub_realloc (*argl, sz); - if (! *argl) - { - grub_free (p); -@@ -431,6 +438,7 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc, - grub_size_t argcnt; - struct grub_arg_list *list; - const struct grub_arg_option *options; -+ grub_size_t sz0, sz1; - - options = extcmd->options; - if (! options) -@@ -443,7 +451,15 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc, - argcnt += ((grub_size_t) argc + 1) / 2 + 1; /* max possible for any option */ - } - -- list = grub_zalloc (sizeof (*list) * i + sizeof (char*) * argcnt); -+ if (grub_mul (sizeof (*list), i, &sz0) || -+ grub_mul (sizeof (char *), argcnt, &sz1) || -+ grub_add (sz0, sz1, &sz0)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ return 0; -+ } -+ -+ list = grub_zalloc (sz0); - if (! list) - return 0; - -diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c -index 50cca304fd0..ff98fb7b62b 100644 ---- a/grub-core/loader/i386/bsd.c -+++ b/grub-core/loader/i386/bsd.c -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - #include - #ifdef GRUB_MACHINE_PCBIOS - #include -@@ -1013,11 +1014,16 @@ grub_netbsd_add_modules (void) - struct grub_netbsd_btinfo_modules *mods; - unsigned i; - grub_err_t err; -+ grub_size_t sz; - - for (mod = netbsd_mods; mod; mod = mod->next) - modcnt++; - -- mods = grub_malloc (sizeof (*mods) + sizeof (mods->mods[0]) * modcnt); -+ if (grub_mul (modcnt, sizeof (mods->mods[0]), &sz) || -+ grub_add (sz, sizeof (*mods), &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ -+ mods = grub_malloc (sz); - if (!mods) - return grub_errno; - -diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c -index e332d5eb4a4..906ec7d6782 100644 ---- a/grub-core/net/dns.c -+++ b/grub-core/net/dns.c -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - - struct dns_cache_element - { -@@ -51,9 +52,15 @@ grub_net_add_dns_server (const struct grub_net_network_level_address *s) - { - int na = dns_servers_alloc * 2; - struct grub_net_network_level_address *ns; -+ grub_size_t sz; -+ - if (na < 8) - na = 8; -- ns = grub_realloc (dns_servers, na * sizeof (ns[0])); -+ -+ if (grub_mul (na, sizeof (ns[0]), &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ -+ ns = grub_realloc (dns_servers, sz); - if (!ns) - return grub_errno; - dns_servers_alloc = na; -diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c -index d57fb72faa8..4dfcc31078d 100644 ---- a/grub-core/normal/charset.c -+++ b/grub-core/normal/charset.c -@@ -48,6 +48,7 @@ - #include - #include - #include -+#include - - #if HAVE_FONT_SOURCE - #include "widthspec.h" -@@ -464,6 +465,7 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen, - { - struct grub_unicode_combining *n; - unsigned j; -+ grub_size_t sz; - - if (!haveout) - continue; -@@ -477,10 +479,14 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen, - n = out->combining_inline; - else if (out->ncomb > (int) ARRAY_SIZE (out->combining_inline)) - { -- n = grub_realloc (out->combining_ptr, -- sizeof (n[0]) * (out->ncomb + 1)); -+ if (grub_add (out->ncomb, 1, &sz) || -+ grub_mul (sz, sizeof (n[0]), &sz)) -+ goto fail; -+ -+ n = grub_realloc (out->combining_ptr, sz); - if (!n) - { -+ fail: - grub_errno = GRUB_ERR_NONE; - continue; - } -diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c -index c57242e2ea9..de03fe63b3d 100644 ---- a/grub-core/normal/cmdline.c -+++ b/grub-core/normal/cmdline.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - - static grub_uint32_t *kill_buf; - -@@ -307,12 +308,21 @@ cl_insert (struct cmdline_term *cl_terms, unsigned nterms, - if (len + (*llen) >= (*max_len)) - { - grub_uint32_t *nbuf; -- (*max_len) *= 2; -- nbuf = grub_realloc ((*buf), sizeof (grub_uint32_t) * (*max_len)); -+ grub_size_t sz; -+ -+ if (grub_mul (*max_len, 2, max_len) || -+ grub_mul (*max_len, sizeof (grub_uint32_t), &sz)) -+ { -+ grub_errno = GRUB_ERR_OUT_OF_RANGE; -+ goto fail; -+ } -+ -+ nbuf = grub_realloc ((*buf), sz); - if (nbuf) - (*buf) = nbuf; - else - { -+ fail: - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - (*max_len) /= 2; -diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c -index f31487c1f58..de64a367c4e 100644 ---- a/grub-core/normal/menu_entry.c -+++ b/grub-core/normal/menu_entry.c -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - - enum update_mode - { -@@ -113,10 +114,18 @@ ensure_space (struct line *linep, int extra) - { - if (linep->max_len < linep->len + extra) - { -- linep->max_len = 2 * (linep->len + extra); -- linep->buf = grub_realloc (linep->buf, (linep->max_len + 1) * sizeof (linep->buf[0])); -+ grub_size_t sz0, sz1; -+ -+ if (grub_add (linep->len, extra, &sz0) || -+ grub_mul (sz0, 2, &sz0) || -+ grub_add (sz0, 1, &sz1) || -+ grub_mul (sz1, sizeof (linep->buf[0]), &sz1)) -+ return 0; -+ -+ linep->buf = grub_realloc (linep->buf, sz1); - if (! linep->buf) - return 0; -+ linep->max_len = sz0; - } - - return 1; -diff --git a/grub-core/script/argv.c b/grub-core/script/argv.c -index 217ec5d1e1b..5751fdd5708 100644 ---- a/grub-core/script/argv.c -+++ b/grub-core/script/argv.c -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - - /* Return nearest power of two that is >= v. */ - static unsigned -@@ -81,11 +82,16 @@ int - grub_script_argv_next (struct grub_script_argv *argv) - { - char **p = argv->args; -+ grub_size_t sz; - - if (argv->args && argv->argc && argv->args[argv->argc - 1] == 0) - return 0; - -- p = grub_realloc (p, round_up_exp ((argv->argc + 2) * sizeof (char *))); -+ if (grub_add (argv->argc, 2, &sz) || -+ grub_mul (sz, sizeof (char *), &sz)) -+ return 1; -+ -+ p = grub_realloc (p, round_up_exp (sz)); - if (! p) - return 1; - -@@ -105,13 +111,19 @@ grub_script_argv_append (struct grub_script_argv *argv, const char *s, - { - grub_size_t a; - char *p = argv->args[argv->argc - 1]; -+ grub_size_t sz; - - if (! s) - return 0; - - a = p ? grub_strlen (p) : 0; - -- p = grub_realloc (p, round_up_exp ((a + slen + 1) * sizeof (char))); -+ if (grub_add (a, slen, &sz) || -+ grub_add (sz, 1, &sz) || -+ grub_mul (sz, sizeof (char), &sz)) -+ return 1; -+ -+ p = grub_realloc (p, round_up_exp (sz)); - if (! p) - return 1; - -diff --git a/grub-core/script/lexer.c b/grub-core/script/lexer.c -index c6bd3172fab..5fb0cbd0bc9 100644 ---- a/grub-core/script/lexer.c -+++ b/grub-core/script/lexer.c -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - - #define yytext_ptr char * - #include "grub_script.tab.h" -@@ -110,10 +111,14 @@ grub_script_lexer_record (struct grub_parser_param *parser, char *str) - old = lexer->recording; - if (lexer->recordlen < len) - lexer->recordlen = len; -- lexer->recordlen *= 2; -+ -+ if (grub_mul (lexer->recordlen, 2, &lexer->recordlen)) -+ goto fail; -+ - lexer->recording = grub_realloc (lexer->recording, lexer->recordlen); - if (!lexer->recording) - { -+ fail: - grub_free (old); - lexer->recordpos = 0; - lexer->recordlen = 0; -@@ -130,7 +135,7 @@ int - grub_script_lexer_yywrap (struct grub_parser_param *parserstate, - const char *input) - { -- grub_size_t len = 0; -+ grub_size_t len = 0, sz; - char *p = 0; - char *line = 0; - YY_BUFFER_STATE buffer; -@@ -168,12 +173,22 @@ grub_script_lexer_yywrap (struct grub_parser_param *parserstate, - } - else if (len && line[len - 1] != '\n') - { -- p = grub_realloc (line, len + 2); -+ if (grub_add (len, 2, &sz)) -+ { -+ grub_free (line); -+ grub_script_yyerror (parserstate, N_("overflow is detected")); -+ return 1; -+ } -+ -+ p = grub_realloc (line, sz); - if (p) - { - p[len++] = '\n'; - p[len] = '\0'; - } -+ else -+ grub_free (line); -+ - line = p; - } - -diff --git a/grub-core/video/bitmap.c b/grub-core/video/bitmap.c -index b2e0315665b..6256e209a6b 100644 ---- a/grub-core/video/bitmap.c -+++ b/grub-core/video/bitmap.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -58,7 +59,7 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap, - enum grub_video_blit_format blit_format) - { - struct grub_video_mode_info *mode_info; -- unsigned int size; -+ grub_size_t size; - - if (!bitmap) - return grub_error (GRUB_ERR_BUG, "invalid argument"); -@@ -137,19 +138,25 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap, - - mode_info->pitch = width * mode_info->bytes_per_pixel; - -- /* Calculate size needed for the data. */ -- size = (width * mode_info->bytes_per_pixel) * height; -+ /* Calculate size needed for the data. */ -+ if (grub_mul (width, mode_info->bytes_per_pixel, &size) || -+ grub_mul (size, height, &size)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ goto fail; -+ } - - (*bitmap)->data = grub_zalloc (size); - if (! (*bitmap)->data) -- { -- grub_free (*bitmap); -- *bitmap = 0; -- -- return grub_errno; -- } -+ goto fail; - - return GRUB_ERR_NONE; -+ -+ fail: -+ grub_free (*bitmap); -+ *bitmap = NULL; -+ -+ return grub_errno; - } - - /* Frees all resources allocated by bitmap. */ -diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c -index 61bd645379b..0157ff7420b 100644 ---- a/grub-core/video/readers/png.c -+++ b/grub-core/video/readers/png.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -301,9 +302,17 @@ grub_png_decode_image_header (struct grub_png_data *data) - data->bpp <<= 1; - - data->color_bits = color_bits; -- data->row_bytes = data->image_width * data->bpp; -+ -+ if (grub_mul (data->image_width, data->bpp, &data->row_bytes)) -+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ - if (data->color_bits <= 4) -- data->row_bytes = (data->image_width * data->color_bits + 7) / 8; -+ { -+ if (grub_mul (data->image_width, data->color_bits + 7, &data->row_bytes)) -+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ -+ data->row_bytes >>= 3; -+ } - - #ifndef GRUB_CPU_WORDS_BIGENDIAN - if (data->is_16bit || data->is_gray || data->is_palette) diff --git a/0230-iso9660-Don-t-leak-memory-on-realloc-failures.patch b/0230-iso9660-Don-t-leak-memory-on-realloc-failures.patch deleted file mode 100644 index 8ec24bd..0000000 --- a/0230-iso9660-Don-t-leak-memory-on-realloc-failures.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Sat, 4 Jul 2020 12:25:09 -0400 -Subject: [PATCH] iso9660: Don't leak memory on realloc() failures - -Signed-off-by: Peter Jones -Reviewed-by: Daniel Kiper -Upstream-commit-id: f2bd30b2fe7 ---- - grub-core/fs/iso9660.c | 24 ++++++++++++++++++++---- - 1 file changed, 20 insertions(+), 4 deletions(-) - -diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c -index 7ba5b300bc1..5ec4433b8f8 100644 ---- a/grub-core/fs/iso9660.c -+++ b/grub-core/fs/iso9660.c -@@ -533,14 +533,20 @@ add_part (struct iterate_dir_ctx *ctx, - { - int size = ctx->symlink ? grub_strlen (ctx->symlink) : 0; - grub_size_t sz; -+ char *new; - - if (grub_add (size, len2, &sz) || - grub_add (sz, 1, &sz)) - return; - -- ctx->symlink = grub_realloc (ctx->symlink, sz); -- if (! ctx->symlink) -- return; -+ new = grub_realloc (ctx->symlink, sz); -+ if (!new) -+ { -+ grub_free (ctx->symlink); -+ ctx->symlink = NULL; -+ return; -+ } -+ ctx->symlink = new; - - grub_memcpy (ctx->symlink + size, part, len2); - ctx->symlink[size + len2] = 0; -@@ -634,7 +640,12 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, - is the length. Both are part of the `Component - Record'. */ - if (ctx->symlink && !ctx->was_continue) -- add_part (ctx, "/", 1); -+ { -+ add_part (ctx, "/", 1); -+ if (grub_errno) -+ return grub_errno; -+ } -+ - add_part (ctx, (char *) &entry->data[pos + 2], - entry->data[pos + 1]); - ctx->was_continue = (entry->data[pos] & 1); -@@ -653,6 +664,11 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, - add_part (ctx, "/", 1); - break; - } -+ -+ /* Check if grub_realloc() failed in add_part(). */ -+ if (grub_errno) -+ return grub_errno; -+ - /* In pos + 1 the length of the `Component Record' is - stored. */ - pos += entry->data[pos + 1] + 2; diff --git a/0231-font-Do-not-load-more-than-one-NAME-section.patch b/0231-font-Do-not-load-more-than-one-NAME-section.patch deleted file mode 100644 index a1da629..0000000 --- a/0231-font-Do-not-load-more-than-one-NAME-section.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Tue, 7 Jul 2020 15:36:26 +0200 -Subject: [PATCH] font: Do not load more than one NAME section - -The GRUB font file can have one NAME section only. Though if somebody -crafts a broken font file with many NAME sections and loads it then the -GRUB leaks memory. So, prevent against that by loading first NAME -section and failing in controlled way on following one. - -Reported-by: Chris Coulson -Signed-off-by: Daniel Kiper -Reviewed-by: Jan Setje-Eilers -Upstream-commit-id: 482814113dc ---- - grub-core/font/font.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 5edb477ac2e..d09bb38d896 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -532,6 +532,12 @@ grub_font_load (const char *filename) - if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME, - sizeof (FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0) - { -+ if (font->name != NULL) -+ { -+ grub_error (GRUB_ERR_BAD_FONT, "invalid font file: too many NAME sections"); -+ goto fail; -+ } -+ - font->name = read_section_as_string (§ion); - if (!font->name) - goto fail; diff --git a/0232-gfxmenu-Fix-double-free-in-load_image.patch b/0232-gfxmenu-Fix-double-free-in-load_image.patch deleted file mode 100644 index 97416b9..0000000 --- a/0232-gfxmenu-Fix-double-free-in-load_image.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexey Makhalov -Date: Wed, 8 Jul 2020 20:41:56 +0000 -Subject: [PATCH] gfxmenu: Fix double free in load_image() - -self->bitmap should be zeroed after free. Otherwise, there is a chance -to double free (USE_AFTER_FREE) it later in rescale_image(). - -Fixes: CID 292472 - -Signed-off-by: Alexey Makhalov -Reviewed-by: Daniel Kiper -Upstream-commit-id: 5d3e84b15a4 ---- - grub-core/gfxmenu/gui_image.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/grub-core/gfxmenu/gui_image.c b/grub-core/gfxmenu/gui_image.c -index 29784ed2d9a..6b2e976f16e 100644 ---- a/grub-core/gfxmenu/gui_image.c -+++ b/grub-core/gfxmenu/gui_image.c -@@ -195,7 +195,10 @@ load_image (grub_gui_image_t self, const char *path) - return grub_errno; - - if (self->bitmap && (self->bitmap != self->raw_bitmap)) -- grub_video_bitmap_destroy (self->bitmap); -+ { -+ grub_video_bitmap_destroy (self->bitmap); -+ self->bitmap = 0; -+ } - if (self->raw_bitmap) - grub_video_bitmap_destroy (self->raw_bitmap); - diff --git a/0233-xnu-Fix-double-free-in-grub_xnu_devprop_add_property.patch b/0233-xnu-Fix-double-free-in-grub_xnu_devprop_add_property.patch deleted file mode 100644 index 235376b..0000000 --- a/0233-xnu-Fix-double-free-in-grub_xnu_devprop_add_property.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexey Makhalov -Date: Wed, 8 Jul 2020 21:30:43 +0000 -Subject: [PATCH] xnu: Fix double free in grub_xnu_devprop_add_property() - -grub_xnu_devprop_add_property() should not free utf8 and utf16 as it get -allocated and freed in the caller. - -Minor improvement: do prop fields initialization after memory allocations. - -Fixes: CID 292442, CID 292457, CID 292460, CID 292466 - -Signed-off-by: Alexey Makhalov -Reviewed-by: Daniel Kiper -Upstream-commit-id: 4d5e2d13519 ---- - grub-core/loader/i386/xnu.c | 19 +++++++++---------- - 1 file changed, 9 insertions(+), 10 deletions(-) - -diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c -index b7d176b5d30..e9e11925972 100644 ---- a/grub-core/loader/i386/xnu.c -+++ b/grub-core/loader/i386/xnu.c -@@ -262,20 +262,19 @@ grub_xnu_devprop_add_property (struct grub_xnu_devprop_device_descriptor *dev, - if (!prop) - return grub_errno; - -+ prop->data = grub_malloc (datalen); -+ if (!prop->data) -+ { -+ grub_free (prop); -+ return grub_errno; -+ } -+ grub_memcpy (prop->data, data, datalen); -+ - prop->name = utf8; - prop->name16 = utf16; - prop->name16len = utf16len; -- - prop->length = datalen; -- prop->data = grub_malloc (prop->length); -- if (!prop->data) -- { -- grub_free (prop->name); -- grub_free (prop->name16); -- grub_free (prop); -- return grub_errno; -- } -- grub_memcpy (prop->data, data, prop->length); -+ - grub_list_push (GRUB_AS_LIST_P (&dev->properties), - GRUB_AS_LIST (prop)); - return GRUB_ERR_NONE; diff --git a/0234-lzma-Make-sure-we-don-t-dereference-past-array.patch b/0234-lzma-Make-sure-we-don-t-dereference-past-array.patch deleted file mode 100644 index d5a31f5..0000000 --- a/0234-lzma-Make-sure-we-don-t-dereference-past-array.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Konrad Rzeszutek Wilk -Date: Thu, 9 Jul 2020 03:05:23 +0000 -Subject: [PATCH] lzma: Make sure we don't dereference past array - -The two dimensional array p->posSlotEncoder[4][64] is being dereferenced -using the GetLenToPosState() macro which checks if len is less than 5, -and if so subtracts 2 from it. If len = 0, that is 0 - 2 = 4294967294. -Obviously we don't want to dereference that far out so we check if the -position found is greater or equal kNumLenToPosStates (4) and bail out. - -N.B.: Upstream LZMA 18.05 and later has this function completely rewritten -without any history. - -Fixes: CID 51526 - -Signed-off-by: Konrad Rzeszutek Wilk -Reviewed-by: Daniel Kiper -Upstream-commit-id: f91e043bda4 ---- - grub-core/lib/LzmaEnc.c | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -diff --git a/grub-core/lib/LzmaEnc.c b/grub-core/lib/LzmaEnc.c -index f2ec04a8c28..753e56a95e3 100644 ---- a/grub-core/lib/LzmaEnc.c -+++ b/grub-core/lib/LzmaEnc.c -@@ -1877,13 +1877,19 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize - } - else - { -- UInt32 posSlot; -+ UInt32 posSlot, lenToPosState; - RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); - p->state = kMatchNextStates[p->state]; - LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); - pos -= LZMA_NUM_REPS; - GetPosSlot(pos, posSlot); -- RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); -+ lenToPosState = GetLenToPosState(len); -+ if (lenToPosState >= kNumLenToPosStates) -+ { -+ p->result = SZ_ERROR_DATA; -+ return CheckErrors(p); -+ } -+ RcTree_Encode(&p->rc, p->posSlotEncoder[lenToPosState], kNumPosSlotBits, posSlot); - - if (posSlot >= kStartPosModelIndex) - { diff --git a/0235-term-Fix-overflow-on-user-inputs.patch b/0235-term-Fix-overflow-on-user-inputs.patch deleted file mode 100644 index b381e45..0000000 --- a/0235-term-Fix-overflow-on-user-inputs.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Konrad Rzeszutek Wilk -Date: Tue, 7 Jul 2020 15:12:25 -0400 -Subject: [PATCH] term: Fix overflow on user inputs - -This requires a very weird input from the serial interface but can cause -an overflow in input_buf (keys) overwriting the next variable (npending) -with the user choice: - -(pahole output) - -struct grub_terminfo_input_state { - int input_buf[6]; /* 0 24 */ - int npending; /* 24 4 */ <- CORRUPT - ...snip... - -The magic string requires causing this is "ESC,O,],0,1,2,q" and we overflow -npending with "q" (aka increase npending to 161). The simplest fix is to -just to disallow overwrites input_buf, which exactly what this patch does. - -Fixes: CID 292449 - -Signed-off-by: Konrad Rzeszutek Wilk -Reviewed-by: Daniel Kiper -Upstream-commit-id: 98dfa546777 ---- - grub-core/term/terminfo.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c -index 537a5c0cb0b..44d0b3b19fb 100644 ---- a/grub-core/term/terminfo.c -+++ b/grub-core/term/terminfo.c -@@ -398,7 +398,7 @@ grub_terminfo_getwh (struct grub_term_output *term) - } - - static void --grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, -+grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, int max_len, - int (*readkey) (struct grub_term_input *term)) - { - int c; -@@ -414,6 +414,9 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, - if (c == -1) \ - return; \ - \ -+ if (*len >= max_len) \ -+ return; \ -+ \ - keys[*len] = c; \ - (*len)++; \ - } -@@ -602,8 +605,8 @@ grub_terminfo_getkey (struct grub_term_input *termi) - return ret; - } - -- grub_terminfo_readkey (termi, data->input_buf, -- &data->npending, data->readkey); -+ grub_terminfo_readkey (termi, data->input_buf, &data->npending, -+ GRUB_TERMINFO_READKEY_MAX_LEN, data->readkey); - - #if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) - if (data->npending == 1 && data->input_buf[0] == GRUB_TERM_ESC diff --git a/0236-udf-Fix-memory-leak.patch b/0236-udf-Fix-memory-leak.patch deleted file mode 100644 index 6b8f092..0000000 --- a/0236-udf-Fix-memory-leak.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Konrad Rzeszutek Wilk -Date: Tue, 7 Jul 2020 22:02:31 -0400 -Subject: [PATCH] udf: Fix memory leak - -Fixes: CID 73796 - -Signed-off-by: Konrad Rzeszutek Wilk -Reviewed-by: Daniel Kiper -Reviewed-by: Jan Setje-Eilers -Upstream-commit-id: 8da62d8183c ---- - grub-core/fs/udf.c | 17 +++++++++++++---- - 1 file changed, 13 insertions(+), 4 deletions(-) - -diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c -index 21ac7f4460d..2ac5c1d0048 100644 ---- a/grub-core/fs/udf.c -+++ b/grub-core/fs/udf.c -@@ -965,8 +965,10 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir, - return 0; - - if (grub_udf_read_icb (dir->data, &dirent.icb, child)) -- return 0; -- -+ { -+ grub_free (child); -+ return 0; -+ } - if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT) - { - /* This is the parent directory. */ -@@ -988,11 +990,18 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir, - dirent.file_ident_length, - (char *) raw)) - != dirent.file_ident_length) -- return 0; -+ { -+ grub_free (child); -+ return 0; -+ } - - filename = read_string (raw, dirent.file_ident_length, 0); - if (!filename) -- grub_print_error (); -+ { -+ /* As the hook won't get called. */ -+ grub_free (child); -+ grub_print_error (); -+ } - - if (filename && hook (filename, type, child, hook_data)) - { diff --git a/0237-multiboot2-Fix-memory-leak-if-grub_create_loader_cmd.patch b/0237-multiboot2-Fix-memory-leak-if-grub_create_loader_cmd.patch deleted file mode 100644 index 18c0a49..0000000 --- a/0237-multiboot2-Fix-memory-leak-if-grub_create_loader_cmd.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Konrad Rzeszutek Wilk -Date: Fri, 26 Jun 2020 10:51:43 -0400 -Subject: [PATCH] multiboot2: Fix memory leak if grub_create_loader_cmdline() - fails - -Fixes: CID 292468 - -Signed-off-by: Konrad Rzeszutek Wilk -Reviewed-by: Daniel Kiper -Upstream-commit-id: cd6760b6289 ---- - grub-core/loader/multiboot_mbi2.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index 53da7861516..0efc660620e 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -1070,7 +1070,11 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, - err = grub_create_loader_cmdline (argc, argv, newmod->cmdline, - newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE); - if (err) -- return err; -+ { -+ grub_free (newmod->cmdline); -+ grub_free (newmod); -+ return err; -+ } - - if (modules_last) - modules_last->next = newmod; diff --git a/0238-tftp-Do-not-use-priority-queue.patch b/0238-tftp-Do-not-use-priority-queue.patch deleted file mode 100644 index 9a1750e..0000000 --- a/0238-tftp-Do-not-use-priority-queue.patch +++ /dev/null @@ -1,278 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexey Makhalov -Date: Thu, 9 Jul 2020 08:10:40 +0000 -Subject: [PATCH] tftp: Do not use priority queue - -There is not need to reassemble the order of blocks. Per RFC 1350, -server must wait for the ACK, before sending next block. Data packets -can be served immediately without putting them to priority queue. - -Logic to handle incoming packet is this: - - if packet block id equal to expected block id, then - process the packet, - - if packet block id is less than expected - this is retransmit - of old packet, then ACK it and drop the packet, - - if packet block id is more than expected - that shouldn't - happen, just drop the packet. - -It makes the tftp receive path code simpler, smaller and faster. -As a benefit, this change fixes CID# 73624 and CID# 96690, caused -by following while loop: - - while (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) == 0) - -where tftph pointer is not moving from one iteration to another, causing -to serve same packet again. Luckily, double serving didn't happen due to -data->block++ during the first iteration. - -Fixes: CID 73624, CID 96690 - -Signed-off-by: Alexey Makhalov -Reviewed-by: Daniel Kiper -Upstream-commit-id: 8316694c4f7 ---- - grub-core/net/tftp.c | 162 ++++++++++++++++----------------------------------- - 1 file changed, 50 insertions(+), 112 deletions(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 4920c3a9783..22badd74316 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -25,7 +25,6 @@ - #include - #include - #include --#include - #include - - GRUB_MOD_LICENSE ("GPLv3+"); -@@ -106,31 +105,8 @@ typedef struct tftp_data - int have_oack; - struct grub_error_saved save_err; - grub_net_udp_socket_t sock; -- grub_priority_queue_t pq; - } *tftp_data_t; - --static int --cmp_block (grub_uint16_t a, grub_uint16_t b) --{ -- grub_int16_t i = (grub_int16_t) (a - b); -- if (i > 0) -- return +1; -- if (i < 0) -- return -1; -- return 0; --} -- --static int --cmp (const void *a__, const void *b__) --{ -- struct grub_net_buff *a_ = *(struct grub_net_buff **) a__; -- struct grub_net_buff *b_ = *(struct grub_net_buff **) b__; -- struct tftphdr *a = (struct tftphdr *) a_->data; -- struct tftphdr *b = (struct tftphdr *) b_->data; -- /* We want the first elements to be on top. */ -- return -cmp_block (grub_be_to_cpu16 (a->u.data.block), grub_be_to_cpu16 (b->u.data.block)); --} -- - static grub_err_t - ack (tftp_data_t data, grub_uint64_t block) - { -@@ -207,73 +183,60 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)), - return GRUB_ERR_NONE; - } - -- err = grub_priority_queue_push (data->pq, &nb); -- if (err) -- return err; -+ /* Ack old/retransmitted block. */ -+ if (grub_be_to_cpu16 (tftph->u.data.block) < data->block + 1) -+ ack (data, grub_be_to_cpu16 (tftph->u.data.block)); -+ /* Ignore unexpected block. */ -+ else if (grub_be_to_cpu16 (tftph->u.data.block) > data->block + 1) -+ grub_dprintf ("tftp", "TFTP unexpected block # %d\n", tftph->u.data.block); -+ else -+ { -+ unsigned size; - -- { -- struct grub_net_buff **nb_top_p, *nb_top; -- while (1) -- { -- nb_top_p = grub_priority_queue_top (data->pq); -- if (!nb_top_p) -- return GRUB_ERR_NONE; -- nb_top = *nb_top_p; -- tftph = (struct tftphdr *) nb_top->data; -- if (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) >= 0) -- break; -- ack (data, grub_be_to_cpu16 (tftph->u.data.block)); -- grub_netbuff_free (nb_top); -- grub_priority_queue_pop (data->pq); -- } -- while (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) == 0) -- { -- unsigned size; -- -- grub_priority_queue_pop (data->pq); -- -- if (file->device->net->packs.count < 50) -+ if (file->device->net->packs.count < 50) -+ { - err = ack (data, data->block + 1); -- else -- { -- file->device->net->stall = 1; -- err = 0; -- } -- if (err) -- return err; -+ if (err) -+ return err; -+ } -+ else -+ file->device->net->stall = 1; - -- err = grub_netbuff_pull (nb_top, sizeof (tftph->opcode) + -- sizeof (tftph->u.data.block)); -- if (err) -- return err; -- size = nb_top->tail - nb_top->data; -+ err = grub_netbuff_pull (nb, sizeof (tftph->opcode) + -+ sizeof (tftph->u.data.block)); -+ if (err) -+ return err; -+ size = nb->tail - nb->data; - -- data->block++; -- if (size < data->block_size) -- { -- if (data->ack_sent < data->block) -- ack (data, data->block); -- file->device->net->eof = 1; -- file->device->net->stall = 1; -- grub_net_udp_close (data->sock); -- data->sock = NULL; -- } -- /* Prevent garbage in broken cards. Is it still necessary -- given that IP implementation has been fixed? -- */ -- if (size > data->block_size) -- { -- err = grub_netbuff_unput (nb_top, size - data->block_size); -- if (err) -- return err; -- } -- /* If there is data, puts packet in socket list. */ -- if ((nb_top->tail - nb_top->data) > 0) -- grub_net_put_packet (&file->device->net->packs, nb_top); -- else -- grub_netbuff_free (nb_top); -- } -- } -+ data->block++; -+ if (size < data->block_size) -+ { -+ if (data->ack_sent < data->block) -+ ack (data, data->block); -+ file->device->net->eof = 1; -+ file->device->net->stall = 1; -+ grub_net_udp_close (data->sock); -+ data->sock = NULL; -+ } -+ /* -+ * Prevent garbage in broken cards. Is it still necessary -+ * given that IP implementation has been fixed? -+ */ -+ if (size > data->block_size) -+ { -+ err = grub_netbuff_unput (nb, size - data->block_size); -+ if (err) -+ return err; -+ } -+ /* If there is data, puts packet in socket list. */ -+ if ((nb->tail - nb->data) > 0) -+ { -+ grub_net_put_packet (&file->device->net->packs, nb); -+ /* Do not free nb. */ -+ return GRUB_ERR_NONE; -+ } -+ } -+ grub_netbuff_free (nb); - return GRUB_ERR_NONE; - case TFTP_ERROR: - data->have_oack = 1; -@@ -287,19 +250,6 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)), - } - } - --static void --destroy_pq (tftp_data_t data) --{ -- struct grub_net_buff **nb_p; -- while ((nb_p = grub_priority_queue_top (data->pq))) -- { -- grub_netbuff_free (*nb_p); -- grub_priority_queue_pop (data->pq); -- } -- -- grub_priority_queue_destroy (data->pq); --} -- - /* Create a normalized copy of the filename. - Compress any string of consecutive forward slashes to a single forward - slash. */ -@@ -395,13 +345,6 @@ tftp_open (struct grub_file *file, const char *filename) - file->not_easily_seekable = 1; - file->data = data; - -- data->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *), cmp); -- if (!data->pq) -- { -- grub_free (data); -- return grub_errno; -- } -- - grub_dprintf ("tftp", "resolving address for %s\n", file->device->net->server); - err = grub_net_resolve_address (file->device->net->server, &addr); - if (err) -@@ -410,7 +353,6 @@ tftp_open (struct grub_file *file, const char *filename) - grub_dprintf ("tftp", "file_size is %llu, block_size is %llu\n", - (unsigned long long)data->file_size, - (unsigned long long)data->block_size); -- destroy_pq (data); - grub_free (data); - return err; - } -@@ -422,7 +364,6 @@ tftp_open (struct grub_file *file, const char *filename) - if (!data->sock) - { - grub_dprintf ("tftp", "connection failed\n"); -- destroy_pq (data); - grub_free (data); - return grub_errno; - } -@@ -436,7 +377,6 @@ tftp_open (struct grub_file *file, const char *filename) - if (err) - { - grub_net_udp_close (data->sock); -- destroy_pq (data); - grub_free (data); - return err; - } -@@ -453,7 +393,6 @@ tftp_open (struct grub_file *file, const char *filename) - if (grub_errno) - { - grub_net_udp_close (data->sock); -- destroy_pq (data); - grub_free (data); - return grub_errno; - } -@@ -496,7 +435,6 @@ tftp_close (struct grub_file *file) - grub_print_error (); - grub_net_udp_close (data->sock); - } -- destroy_pq (data); - grub_free (data); - return GRUB_ERR_NONE; - } diff --git a/0239-multiboot2-Set-min-address-for-mbi-allocation-to-0x1.patch b/0239-multiboot2-Set-min-address-for-mbi-allocation-to-0x1.patch deleted file mode 100644 index b68f3a1..0000000 --- a/0239-multiboot2-Set-min-address-for-mbi-allocation-to-0x1.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lukasz Hawrylko -Date: Mon, 16 Dec 2019 11:15:55 +0100 -Subject: [PATCH] multiboot2: Set min address for mbi allocation to 0x1000 - -In some cases GRUB2 allocates multiboot2 structure at 0 address, that is -a confusing behavior. Consumers of that structure can have internal NULL-checks -that will throw an error when get a pointer to data allocated at address 0. -To prevent that, define min address for mbi allocation on x86 and x86_64 -platforms. - -Signed-off-by: Lukasz Hawrylko -Reviewed-by: Daniel Kiper -Upstream-commit-id: 0f3f5b7c13f ---- - grub-core/loader/multiboot_mbi2.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index 0efc660620e..e88c9f4884f 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -48,6 +48,12 @@ - #define HAS_VGA_TEXT 0 - #endif - -+#if defined (__i386__) || defined (__x86_64__) -+#define MBI_MIN_ADDR 0x1000 -+#else -+#define MBI_MIN_ADDR 0 -+#endif -+ - struct module - { - struct module *next; -@@ -708,7 +714,7 @@ grub_multiboot2_make_mbi (grub_uint32_t *target) - COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0); - - err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, -- 0, 0xffffffff - bufsize, -+ MBI_MIN_ADDR, 0xffffffff - bufsize, - bufsize, MULTIBOOT_TAG_ALIGN, - GRUB_RELOCATOR_PREFERENCE_NONE, 1); - if (err) diff --git a/0240-relocator-Protect-grub_relocator_alloc_chunk_addr-in.patch b/0240-relocator-Protect-grub_relocator_alloc_chunk_addr-in.patch deleted file mode 100644 index 3c054cc..0000000 --- a/0240-relocator-Protect-grub_relocator_alloc_chunk_addr-in.patch +++ /dev/null @@ -1,147 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexey Makhalov -Date: Wed, 15 Jul 2020 06:42:37 +0000 -Subject: [PATCH] relocator: Protect grub_relocator_alloc_chunk_addr() input - args against integer underflow/overflow - -Use arithmetic macros from safemath.h to accomplish it. In this commit, -I didn't want to be too paranoid to check every possible math equation -for overflow/underflow. Only obvious places (with non zero chance of -overflow/underflow) were refactored. - -Signed-off-by: Alexey Makhalov -Reviewed-by: Daniel Kiper -Upstream-commit-id: ebb15735f10 ---- - grub-core/loader/i386/linux.c | 9 +++++++-- - grub-core/loader/i386/pc/linux.c | 9 +++++++-- - grub-core/loader/i386/xen.c | 12 ++++++++++-- - grub-core/loader/xnu.c | 11 +++++++---- - 4 files changed, 31 insertions(+), 10 deletions(-) - -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 201e6597c6d..90f2315f847 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -37,6 +37,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -548,9 +549,13 @@ grub_linux_boot (void) - - { - grub_relocator_chunk_t ch; -+ grub_size_t sz; -+ -+ if (grub_add (ctx.real_size, efi_mmap_size, &sz)) -+ return GRUB_ERR_OUT_OF_RANGE; -+ - err = grub_relocator_alloc_chunk_addr (relocator, &ch, -- ctx.real_mode_target, -- (ctx.real_size + efi_mmap_size)); -+ ctx.real_mode_target, sz); - if (err) - return err; - real_mode_mem = get_virtual_current_address (ch); -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 0bf0e13d647..33d1196b1e2 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -231,8 +232,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS; - - real_size = setup_sects << GRUB_DISK_SECTOR_BITS; -- grub_linux16_prot_size = grub_file_size (file) -- - real_size - GRUB_DISK_SECTOR_SIZE; -+ if (grub_sub (grub_file_size (file), real_size, &grub_linux16_prot_size) || -+ grub_sub (grub_linux16_prot_size, GRUB_DISK_SECTOR_SIZE, &grub_linux16_prot_size)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ goto fail; -+ } - - if (! grub_linux_is_bzimage - && GRUB_LINUX_ZIMAGE_ADDR + grub_linux16_prot_size -diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c -index 8f662c8ac89..cd24874ca32 100644 ---- a/grub-core/loader/i386/xen.c -+++ b/grub-core/loader/i386/xen.c -@@ -41,6 +41,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -636,6 +637,7 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), - grub_relocator_chunk_t ch; - grub_addr_t kern_start; - grub_addr_t kern_end; -+ grub_size_t sz; - - if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -703,8 +705,14 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), - - xen_state.max_addr = ALIGN_UP (kern_end, PAGE_SIZE); - -- err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, kern_start, -- kern_end - kern_start); -+ -+ if (grub_sub (kern_end, kern_start, &sz)) -+ { -+ err = GRUB_ERR_OUT_OF_RANGE; -+ goto fail; -+ } -+ -+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, kern_start, sz); - if (err) - goto fail; - kern_chunk_src = get_virtual_current_address (ch); -diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c -index 2f0ebd0b8bf..3fd653993f7 100644 ---- a/grub-core/loader/xnu.c -+++ b/grub-core/loader/xnu.c -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -60,15 +61,17 @@ grub_xnu_heap_malloc (int size, void **src, grub_addr_t *target) - { - grub_err_t err; - grub_relocator_chunk_t ch; -+ grub_addr_t tgt; -+ -+ if (grub_add (grub_xnu_heap_target_start, grub_xnu_heap_size, &tgt)) -+ return GRUB_ERR_OUT_OF_RANGE; - -- err = grub_relocator_alloc_chunk_addr (grub_xnu_relocator, &ch, -- grub_xnu_heap_target_start -- + grub_xnu_heap_size, size); -+ err = grub_relocator_alloc_chunk_addr (grub_xnu_relocator, &ch, tgt, size); - if (err) - return err; - - *src = get_virtual_current_address (ch); -- *target = grub_xnu_heap_target_start + grub_xnu_heap_size; -+ *target = tgt; - grub_xnu_heap_size += size; - grub_dprintf ("xnu", "val=%p\n", *src); - return GRUB_ERR_NONE; diff --git a/0241-relocator-Protect-grub_relocator_alloc_chunk_align-m.patch b/0241-relocator-Protect-grub_relocator_alloc_chunk_align-m.patch deleted file mode 100644 index 2ac5395..0000000 --- a/0241-relocator-Protect-grub_relocator_alloc_chunk_align-m.patch +++ /dev/null @@ -1,335 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexey Makhalov -Date: Wed, 8 Jul 2020 01:44:38 +0000 -Subject: [PATCH] relocator: Protect grub_relocator_alloc_chunk_align() - max_addr against integer underflow - -This commit introduces integer underflow mitigation in max_addr calculation -in grub_relocator_alloc_chunk_align() invocation. - -It consists of 2 fixes: - 1. Introduced grub_relocator_alloc_chunk_align_safe() wrapper function to perform - sanity check for min/max and size values, and to make safe invocation of - grub_relocator_alloc_chunk_align() with validated max_addr value. Replace all - invocations such as grub_relocator_alloc_chunk_align(..., min_addr, max_addr - size, size, ...) - by grub_relocator_alloc_chunk_align_safe(..., min_addr, max_addr, size, ...). - 2. Introduced UP_TO_TOP32(s) macro for the cases where max_addr is 32-bit top - address (0xffffffff - size + 1) or similar. - -Signed-off-by: Alexey Makhalov -Reviewed-by: Daniel Kiper -Upstream-commit-id: 10498c8ba17 ---- - grub-core/lib/i386/relocator.c | 28 +++++++++++----------------- - grub-core/lib/mips/relocator.c | 6 ++---- - grub-core/lib/powerpc/relocator.c | 6 ++---- - grub-core/lib/x86_64/efi/relocator.c | 7 +++---- - grub-core/loader/i386/linux.c | 5 ++--- - grub-core/loader/i386/multiboot_mbi.c | 7 +++---- - grub-core/loader/i386/pc/linux.c | 6 ++---- - grub-core/loader/mips/linux.c | 9 +++------ - grub-core/loader/multiboot.c | 2 +- - grub-core/loader/multiboot_elfxx.c | 10 +++++----- - grub-core/loader/multiboot_mbi2.c | 10 +++++----- - grub-core/loader/xnu_resume.c | 2 +- - include/grub/relocator.h | 29 +++++++++++++++++++++++++++++ - 13 files changed, 69 insertions(+), 58 deletions(-) - -diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c -index 71dd4f0ab0c..34cbe834fa3 100644 ---- a/grub-core/lib/i386/relocator.c -+++ b/grub-core/lib/i386/relocator.c -@@ -83,11 +83,10 @@ grub_relocator32_boot (struct grub_relocator *rel, - /* Specific memory range due to Global Descriptor Table for use by payload - that we will store in returned chunk. The address range and preference - are based on "THE LINUX/x86 BOOT PROTOCOL" specification. */ -- err = grub_relocator_alloc_chunk_align (rel, &ch, 0x1000, -- 0x9a000 - RELOCATOR_SIZEOF (32), -- RELOCATOR_SIZEOF (32), 16, -- GRUB_RELOCATOR_PREFERENCE_LOW, -- avoid_efi_bootservices); -+ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, 0x1000, 0x9a000, -+ RELOCATOR_SIZEOF (32), 16, -+ GRUB_RELOCATOR_PREFERENCE_LOW, -+ avoid_efi_bootservices); - if (err) - return err; - -@@ -125,13 +124,10 @@ grub_relocator16_boot (struct grub_relocator *rel, - grub_relocator_chunk_t ch; - - /* Put it higher than the byte it checks for A20 check. */ -- err = grub_relocator_alloc_chunk_align (rel, &ch, 0x8010, -- 0xa0000 - RELOCATOR_SIZEOF (16) -- - GRUB_RELOCATOR16_STACK_SIZE, -- RELOCATOR_SIZEOF (16) -- + GRUB_RELOCATOR16_STACK_SIZE, 16, -- GRUB_RELOCATOR_PREFERENCE_NONE, -- 0); -+ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, 0x8010, 0xa0000, -+ RELOCATOR_SIZEOF (16) + -+ GRUB_RELOCATOR16_STACK_SIZE, 16, -+ GRUB_RELOCATOR_PREFERENCE_NONE, 0); - if (err) - return err; - -@@ -183,11 +179,9 @@ grub_relocator64_boot (struct grub_relocator *rel, - void *relst; - grub_relocator_chunk_t ch; - -- err = grub_relocator_alloc_chunk_align (rel, &ch, min_addr, -- max_addr - RELOCATOR_SIZEOF (64), -- RELOCATOR_SIZEOF (64), 16, -- GRUB_RELOCATOR_PREFERENCE_NONE, -- 0); -+ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, min_addr, max_addr, -+ RELOCATOR_SIZEOF (64), 16, -+ GRUB_RELOCATOR_PREFERENCE_NONE, 0); - if (err) - return err; - -diff --git a/grub-core/lib/mips/relocator.c b/grub-core/lib/mips/relocator.c -index 9d5f49cb93a..743b213e695 100644 ---- a/grub-core/lib/mips/relocator.c -+++ b/grub-core/lib/mips/relocator.c -@@ -120,10 +120,8 @@ grub_relocator32_boot (struct grub_relocator *rel, - unsigned i; - grub_addr_t vtarget; - -- err = grub_relocator_alloc_chunk_align (rel, &ch, 0, -- (0xffffffff - stateset_size) -- + 1, stateset_size, -- sizeof (grub_uint32_t), -+ err = grub_relocator_alloc_chunk_align (rel, &ch, 0, UP_TO_TOP32 (stateset_size), -+ stateset_size, sizeof (grub_uint32_t), - GRUB_RELOCATOR_PREFERENCE_NONE, 0); - if (err) - return err; -diff --git a/grub-core/lib/powerpc/relocator.c b/grub-core/lib/powerpc/relocator.c -index bdf2b111be7..8ffb8b68683 100644 ---- a/grub-core/lib/powerpc/relocator.c -+++ b/grub-core/lib/powerpc/relocator.c -@@ -115,10 +115,8 @@ grub_relocator32_boot (struct grub_relocator *rel, - unsigned i; - grub_relocator_chunk_t ch; - -- err = grub_relocator_alloc_chunk_align (rel, &ch, 0, -- (0xffffffff - stateset_size) -- + 1, stateset_size, -- sizeof (grub_uint32_t), -+ err = grub_relocator_alloc_chunk_align (rel, &ch, 0, UP_TO_TOP32 (stateset_size), -+ stateset_size, sizeof (grub_uint32_t), - GRUB_RELOCATOR_PREFERENCE_NONE, 0); - if (err) - return err; -diff --git a/grub-core/lib/x86_64/efi/relocator.c b/grub-core/lib/x86_64/efi/relocator.c -index 3caef7a4021..7d200a125ee 100644 ---- a/grub-core/lib/x86_64/efi/relocator.c -+++ b/grub-core/lib/x86_64/efi/relocator.c -@@ -50,10 +50,9 @@ grub_relocator64_efi_boot (struct grub_relocator *rel, - * 64-bit relocator code may live above 4 GiB quite well. - * However, I do not want ask for problems. Just in case. - */ -- err = grub_relocator_alloc_chunk_align (rel, &ch, 0, -- 0x100000000 - RELOCATOR_SIZEOF (64_efi), -- RELOCATOR_SIZEOF (64_efi), 16, -- GRUB_RELOCATOR_PREFERENCE_NONE, 1); -+ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, 0, 0x100000000, -+ RELOCATOR_SIZEOF (64_efi), 16, -+ GRUB_RELOCATOR_PREFERENCE_NONE, 1); - if (err) - return err; - -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 90f2315f847..7d0c987cd91 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -182,9 +182,8 @@ allocate_pages (grub_size_t prot_size, grub_size_t *align, - for (; err && *align + 1 > min_align; (*align)--) - { - grub_errno = GRUB_ERR_NONE; -- err = grub_relocator_alloc_chunk_align (relocator, &ch, -- 0x1000000, -- 0xffffffff & ~prot_size, -+ err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000000, -+ UP_TO_TOP32 (prot_size), - prot_size, 1 << *align, - GRUB_RELOCATOR_PREFERENCE_LOW, - 1); -diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c -index ad3cc292fd1..a67d9d0a808 100644 ---- a/grub-core/loader/i386/multiboot_mbi.c -+++ b/grub-core/loader/i386/multiboot_mbi.c -@@ -466,10 +466,9 @@ grub_multiboot_make_mbi (grub_uint32_t *target) - - bufsize = grub_multiboot_get_mbi_size (); - -- err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, -- 0x10000, 0xa0000 - bufsize, -- bufsize, 4, -- GRUB_RELOCATOR_PREFERENCE_NONE, 0); -+ err = grub_relocator_alloc_chunk_align_safe (grub_multiboot_relocator, &ch, -+ 0x10000, 0xa0000, bufsize, 4, -+ GRUB_RELOCATOR_PREFERENCE_NONE, 0); - if (err) - return err; - ptrorig = get_virtual_current_address (ch); -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 33d1196b1e2..f1ad185ddc2 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -463,10 +463,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - - { - grub_relocator_chunk_t ch; -- err = grub_relocator_alloc_chunk_align (relocator, &ch, -- addr_min, addr_max - size, -- size, 0x1000, -- GRUB_RELOCATOR_PREFERENCE_HIGH, 0); -+ err = grub_relocator_alloc_chunk_align_safe (relocator, &ch, addr_min, addr_max, size, -+ 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 0); - if (err) - return err; - initrd_chunk = get_virtual_current_address (ch); -diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c -index 7b723bf189d..e4ed95921df 100644 ---- a/grub-core/loader/mips/linux.c -+++ b/grub-core/loader/mips/linux.c -@@ -442,12 +442,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - { - grub_relocator_chunk_t ch; - -- err = grub_relocator_alloc_chunk_align (relocator, &ch, -- (target_addr & 0x1fffffff) -- + linux_size + 0x10000, -- (0x10000000 - size), -- size, 0x10000, -- GRUB_RELOCATOR_PREFERENCE_NONE, 0); -+ err = grub_relocator_alloc_chunk_align_safe (relocator, &ch, (target_addr & 0x1fffffff) + -+ linux_size + 0x10000, 0x10000000, size, -+ 0x10000, GRUB_RELOCATOR_PREFERENCE_NONE, 0); - - if (err) - goto fail; -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 3e6ad166dc9..3e286908dda 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -404,7 +404,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - { - grub_relocator_chunk_t ch; - err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, -- lowest_addr, (0xffffffff - size) + 1, -+ lowest_addr, UP_TO_TOP32 (size), - size, MULTIBOOT_MOD_ALIGN, - GRUB_RELOCATOR_PREFERENCE_NONE, 1); - if (err) -diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c -index cc6853692a8..f2318e0d165 100644 ---- a/grub-core/loader/multiboot_elfxx.c -+++ b/grub-core/loader/multiboot_elfxx.c -@@ -109,10 +109,10 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - if (load_size > mld->max_addr || mld->min_addr > mld->max_addr - load_size) - return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); - -- err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, -- mld->min_addr, mld->max_addr - load_size, -- load_size, mld->align ? mld->align : 1, -- mld->preference, mld->avoid_efi_boot_services); -+ err = grub_relocator_alloc_chunk_align_safe (GRUB_MULTIBOOT (relocator), &ch, -+ mld->min_addr, mld->max_addr, -+ load_size, mld->align ? mld->align : 1, -+ mld->preference, mld->avoid_efi_boot_services); - - if (err) - { -@@ -256,7 +256,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - continue; - - err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, 0, -- (0xffffffff - sh->sh_size) + 1, -+ UP_TO_TOP32 (sh->sh_size), - sh->sh_size, sh->sh_addralign, - GRUB_RELOCATOR_PREFERENCE_NONE, - mld->avoid_efi_boot_services); -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index e88c9f4884f..9a943d7bdd7 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -301,10 +301,10 @@ grub_multiboot2_load (grub_file_t file, const char *filename) - return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); - } - -- err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, -- mld.min_addr, mld.max_addr - code_size, -- code_size, mld.align ? mld.align : 1, -- mld.preference, keep_bs); -+ err = grub_relocator_alloc_chunk_align_safe (grub_multiboot2_relocator, &ch, -+ mld.min_addr, mld.max_addr, -+ code_size, mld.align ? mld.align : 1, -+ mld.preference, keep_bs); - } - else - err = grub_relocator_alloc_chunk_addr (grub_multiboot2_relocator, -@@ -714,7 +714,7 @@ grub_multiboot2_make_mbi (grub_uint32_t *target) - COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0); - - err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, -- MBI_MIN_ADDR, 0xffffffff - bufsize, -+ MBI_MIN_ADDR, UP_TO_TOP32 (bufsize), - bufsize, MULTIBOOT_TAG_ALIGN, - GRUB_RELOCATOR_PREFERENCE_NONE, 1); - if (err) -diff --git a/grub-core/loader/xnu_resume.c b/grub-core/loader/xnu_resume.c -index 8089804d482..d648ef0cd3a 100644 ---- a/grub-core/loader/xnu_resume.c -+++ b/grub-core/loader/xnu_resume.c -@@ -129,7 +129,7 @@ grub_xnu_resume (char *imagename) - { - grub_relocator_chunk_t ch; - err = grub_relocator_alloc_chunk_align (grub_xnu_relocator, &ch, 0, -- (0xffffffff - hibhead.image_size) + 1, -+ UP_TO_TOP32 (hibhead.image_size), - hibhead.image_size, - GRUB_XNU_PAGESIZE, - GRUB_RELOCATOR_PREFERENCE_NONE, 0); -diff --git a/include/grub/relocator.h b/include/grub/relocator.h -index 24d8672d22c..1b3bdd92ac6 100644 ---- a/include/grub/relocator.h -+++ b/include/grub/relocator.h -@@ -49,6 +49,35 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel, - int preference, - int avoid_efi_boot_services); - -+/* -+ * Wrapper for grub_relocator_alloc_chunk_align() with purpose of -+ * protecting against integer underflow. -+ * -+ * Compare to its callee, max_addr has different meaning here. -+ * It covers entire chunk and not just start address of the chunk. -+ */ -+static inline grub_err_t -+grub_relocator_alloc_chunk_align_safe (struct grub_relocator *rel, -+ grub_relocator_chunk_t *out, -+ grub_phys_addr_t min_addr, -+ grub_phys_addr_t max_addr, -+ grub_size_t size, grub_size_t align, -+ int preference, -+ int avoid_efi_boot_services) -+{ -+ /* Sanity check and ensure following equation (max_addr - size) is safe. */ -+ if (max_addr < size || (max_addr - size) < min_addr) -+ return GRUB_ERR_OUT_OF_RANGE; -+ -+ return grub_relocator_alloc_chunk_align (rel, out, min_addr, -+ max_addr - size, -+ size, align, preference, -+ avoid_efi_boot_services); -+} -+ -+/* Top 32-bit address minus s bytes and plus 1 byte. */ -+#define UP_TO_TOP32(s) ((~(s) & 0xffffffff) + 1) -+ - #define GRUB_RELOCATOR_PREFERENCE_NONE 0 - #define GRUB_RELOCATOR_PREFERENCE_LOW 1 - #define GRUB_RELOCATOR_PREFERENCE_HIGH 2 diff --git a/0242-script-Remove-unused-fields-from-grub_script_functio.patch b/0242-script-Remove-unused-fields-from-grub_script_functio.patch deleted file mode 100644 index 93beaac..0000000 --- a/0242-script-Remove-unused-fields-from-grub_script_functio.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Chris Coulson -Date: Fri, 10 Jul 2020 11:21:14 +0100 -Subject: [PATCH] script: Remove unused fields from grub_script_function struct - -Signed-off-by: Chris Coulson -Reviewed-by: Daniel Kiper -Upstream-commit-id: d04089c8e52 ---- - include/grub/script_sh.h | 5 ----- - 1 file changed, 5 deletions(-) - -diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h -index 360c2be1f05..b382bcf09bc 100644 ---- a/include/grub/script_sh.h -+++ b/include/grub/script_sh.h -@@ -359,13 +359,8 @@ struct grub_script_function - /* The script function. */ - struct grub_script *func; - -- /* The flags. */ -- unsigned flags; -- - /* The next element. */ - struct grub_script_function *next; -- -- int references; - }; - typedef struct grub_script_function *grub_script_function_t; - diff --git a/0243-script-Avoid-a-use-after-free-when-redefining-a-func.patch b/0243-script-Avoid-a-use-after-free-when-redefining-a-func.patch deleted file mode 100644 index 4435a7d..0000000 --- a/0243-script-Avoid-a-use-after-free-when-redefining-a-func.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Chris Coulson -Date: Fri, 10 Jul 2020 14:41:45 +0100 -Subject: [PATCH] script: Avoid a use-after-free when redefining a function - during execution - -Defining a new function with the same name as a previously defined -function causes the grub_script and associated resources for the -previous function to be freed. If the previous function is currently -executing when a function with the same name is defined, this results -in use-after-frees when processing subsequent commands in the original -function. - -Instead, reject a new function definition if it has the same name as -a previously defined function, and that function is currently being -executed. Although a behavioural change, this should be backwards -compatible with existing configurations because they can't be -dependent on the current behaviour without being broken. - -Signed-off-by: Chris Coulson -Reviewed-by: Daniel Kiper -Upstream-commit-id: f6253a1f540 ---- - grub-core/script/execute.c | 2 ++ - grub-core/script/function.c | 16 +++++++++++++--- - include/grub/script_sh.h | 2 ++ - grub-core/script/parser.y | 3 ++- - 4 files changed, 19 insertions(+), 4 deletions(-) - -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index b55e171c931..d2f02cc5b38 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -872,7 +872,9 @@ grub_script_function_call (grub_script_function_t func, int argc, char **args) - old_scope = scope; - scope = &new_scope; - -+ func->executing++; - ret = grub_script_execute (func->func); -+ func->executing--; - - function_return = 0; - active_loops = loops; -diff --git a/grub-core/script/function.c b/grub-core/script/function.c -index d36655e510f..3aad04bf9dd 100644 ---- a/grub-core/script/function.c -+++ b/grub-core/script/function.c -@@ -34,6 +34,7 @@ grub_script_function_create (struct grub_script_arg *functionname_arg, - func = (grub_script_function_t) grub_malloc (sizeof (*func)); - if (! func) - return 0; -+ func->executing = 0; - - func->name = grub_strdup (functionname_arg->str); - if (! func->name) -@@ -60,10 +61,19 @@ grub_script_function_create (struct grub_script_arg *functionname_arg, - grub_script_function_t q; - - q = *p; -- grub_script_free (q->func); -- q->func = cmd; - grub_free (func); -- func = q; -+ if (q->executing > 0) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, -+ N_("attempt to redefine a function being executed")); -+ func = NULL; -+ } -+ else -+ { -+ grub_script_free (q->func); -+ q->func = cmd; -+ func = q; -+ } - } - else - { -diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h -index b382bcf09bc..6c48e075122 100644 ---- a/include/grub/script_sh.h -+++ b/include/grub/script_sh.h -@@ -361,6 +361,8 @@ struct grub_script_function - - /* The next element. */ - struct grub_script_function *next; -+ -+ unsigned executing; - }; - typedef struct grub_script_function *grub_script_function_t; - -diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y -index 4f0ab8319e3..f80b86b6f15 100644 ---- a/grub-core/script/parser.y -+++ b/grub-core/script/parser.y -@@ -289,7 +289,8 @@ function: "function" "name" - grub_script_mem_free (state->func_mem); - else { - script->children = state->scripts; -- grub_script_function_create ($2, script); -+ if (!grub_script_function_create ($2, script)) -+ grub_script_free (script); - } - - state->scripts = $3; diff --git a/0244-relocator-Fix-grub_relocator_alloc_chunk_align-top-m.patch b/0244-relocator-Fix-grub_relocator_alloc_chunk_align-top-m.patch deleted file mode 100644 index 850fef7..0000000 --- a/0244-relocator-Fix-grub_relocator_alloc_chunk_align-top-m.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexey Makhalov -Date: Fri, 17 Jul 2020 05:17:26 +0000 -Subject: [PATCH] relocator: Fix grub_relocator_alloc_chunk_align() top memory - allocation - -Current implementation of grub_relocator_alloc_chunk_align() -does not allow allocation of the top byte. - -Assuming input args are: - max_addr = 0xfffff000; - size = 0x1000; - -And this is valid. But following overflow protection will -unnecessarily move max_addr one byte down (to 0xffffefff): - if (max_addr > ~size) - max_addr = ~size; - -~size + 1 will fix the situation. In addition, check size -for non zero to do not zero max_addr. - -Signed-off-by: Alexey Makhalov -Reviewed-by: Daniel Kiper -Upstream-commit-id: ab80a97eb1f ---- - grub-core/lib/relocator.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c -index 5847aac3643..f2c1944c28d 100644 ---- a/grub-core/lib/relocator.c -+++ b/grub-core/lib/relocator.c -@@ -1386,8 +1386,8 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel, - }; - grub_addr_t min_addr2 = 0, max_addr2; - -- if (max_addr > ~size) -- max_addr = ~size; -+ if (size && (max_addr > ~size)) -+ max_addr = ~size + 1; - - #ifdef GRUB_MACHINE_PCBIOS - if (min_addr < 0x1000) diff --git a/0245-hfsplus-fix-two-more-overflows.patch b/0245-hfsplus-fix-two-more-overflows.patch deleted file mode 100644 index 937918f..0000000 --- a/0245-hfsplus-fix-two-more-overflows.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Sun, 19 Jul 2020 14:43:31 -0400 -Subject: [PATCH] hfsplus: fix two more overflows - -Both node->size and node->namelen come from the supplied filesystem, -which may be user-supplied. We can't trust them for the math unless we -know they don't overflow; making sure they go through calloc() first -will give us that. - -Signed-off-by: Peter Jones -Reviewed-by: Darren Kenny -Upstream-commit-id: b4915078903 ---- - grub-core/fs/hfsplus.c | 11 ++++++++--- - 1 file changed, 8 insertions(+), 3 deletions(-) - -diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c -index dae43becc97..9c4e4c88c99 100644 ---- a/grub-core/fs/hfsplus.c -+++ b/grub-core/fs/hfsplus.c -@@ -31,6 +31,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -475,8 +476,12 @@ grub_hfsplus_read_symlink (grub_fshelp_node_t node) - { - char *symlink; - grub_ssize_t numread; -+ grub_size_t sz = node->size; - -- symlink = grub_malloc (node->size + 1); -+ if (grub_add (sz, 1, &sz)) -+ return NULL; -+ -+ symlink = grub_malloc (sz); - if (!symlink) - return 0; - -@@ -715,8 +720,8 @@ list_nodes (void *record, void *hook_arg) - if (type == GRUB_FSHELP_UNKNOWN) - return 0; - -- filename = grub_malloc (grub_be_to_cpu16 (catkey->namelen) -- * GRUB_MAX_UTF8_PER_UTF16 + 1); -+ filename = grub_calloc (grub_be_to_cpu16 (catkey->namelen), -+ GRUB_MAX_UTF8_PER_UTF16 + 1); - if (! filename) - return 0; - diff --git a/0246-lvm-fix-two-more-potential-data-dependent-alloc-over.patch b/0246-lvm-fix-two-more-potential-data-dependent-alloc-over.patch deleted file mode 100644 index 31e7f07..0000000 --- a/0246-lvm-fix-two-more-potential-data-dependent-alloc-over.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Sun, 19 Jul 2020 15:48:20 -0400 -Subject: [PATCH] lvm: fix two more potential data-dependent alloc overflows - -It appears to be possible to make a (possibly invalid) lvm PV with a -metadata size field that overflows our type when adding it to the -address we've allocated. Even if it doesn't, it may be possible to do -so with the math using the outcome of that as an operand. Check them -both. - -Signed-off-by: Peter Jones -Signed-off-by: Darren Kenny -Upstream-commit-id: 45ec6046ea0 ---- - grub-core/disk/lvm.c | 47 +++++++++++++++++++++++++++++++++++++++-------- - 1 file changed, 39 insertions(+), 8 deletions(-) - -diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c -index 8e76d1ae121..cca8ec668ba 100644 ---- a/grub-core/disk/lvm.c -+++ b/grub-core/disk/lvm.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - - #ifdef GRUB_UTIL - #include -@@ -102,10 +103,11 @@ grub_lvm_detect (grub_disk_t disk, - { - grub_err_t err; - grub_uint64_t mda_offset, mda_size; -+ grub_size_t ptr; - char buf[GRUB_LVM_LABEL_SIZE]; - char vg_id[GRUB_LVM_ID_STRLEN+1]; - char pv_id[GRUB_LVM_ID_STRLEN+1]; -- char *metadatabuf, *vgname; -+ char *metadatabuf, *mda_end, *vgname; - const char *p, *q; - struct grub_lvm_label_header *lh = (struct grub_lvm_label_header *) buf; - struct grub_lvm_pv_header *pvh; -@@ -206,19 +208,31 @@ grub_lvm_detect (grub_disk_t disk, - grub_le_to_cpu64 (rlocn->size) - - grub_le_to_cpu64 (mdah->size)); - } -- p = q = metadatabuf + grub_le_to_cpu64 (rlocn->offset); - -- while (*q != ' ' && q < metadatabuf + mda_size) -- q++; -- -- if (q == metadatabuf + mda_size) -+ if (grub_add ((grub_size_t)metadatabuf, -+ (grub_size_t)grub_le_to_cpu64 (rlocn->offset), -+ &ptr)) - { -+error_parsing_metadata: - #ifdef GRUB_UTIL - grub_util_info ("error parsing metadata"); - #endif - goto fail2; - } - -+ p = q = (char *)ptr; -+ -+ if (grub_add ((grub_size_t)metadatabuf, (grub_size_t)mda_size, &ptr)) -+ goto error_parsing_metadata; -+ -+ mda_end = (char *)ptr; -+ -+ while (*q != ' ' && q < mda_end) -+ q++; -+ -+ if (q == mda_end) -+ goto error_parsing_metadata; -+ - vgname_len = q - p; - vgname = grub_malloc (vgname_len + 1); - if (!vgname) -@@ -368,8 +382,25 @@ grub_lvm_detect (grub_disk_t disk, - { - const char *iptr; - char *optr; -- lv->fullname = grub_malloc (sizeof ("lvm/") - 1 + 2 * vgname_len -- + 1 + 2 * s + 1); -+ -+ /* this is kind of hard to read with our safe (but rather -+ * baroque) math primatives, but it boils down to: -+ * -+ * sz0 = vgname_len * 2 + 1 -+ * + s * 2 + 1 -+ * + sizeof ("lvm/") - 1; -+ */ -+ grub_size_t sz0 = vgname_len, sz1 = s; -+ -+ if (grub_mul (sz0, 2, &sz0) || -+ grub_add (sz0, 1, &sz0) || -+ grub_mul (sz1, 2, &sz1) || -+ grub_add (sz1, 1, &sz1) || -+ grub_add (sz0, sz1, &sz0) || -+ grub_add (sz0, sizeof ("lvm/") - 1, &sz0)) -+ goto lvs_fail; -+ -+ lv->fullname = grub_malloc (sz0); - if (!lv->fullname) - goto lvs_fail; - diff --git a/0247-emu-make-grub_free-NULL-safe.patch b/0247-emu-make-grub_free-NULL-safe.patch deleted file mode 100644 index 64ecc34..0000000 --- a/0247-emu-make-grub_free-NULL-safe.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Sun, 19 Jul 2020 16:08:08 -0400 -Subject: [PATCH] emu: make grub_free(NULL) safe - -The grub_free() implementation in kern/mm.c safely handles NULL -pointers, and code at many places depends on this. We don't know that -the same is true on all host OSes, so we need to handle the same -behavior in grub-emu's implementation. - -Signed-off-by: Peter Jones -Reviewed-by: Darren Kenny -Upstream-commit-id: 96bb109e658 ---- - grub-core/kern/emu/mm.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c -index 145b01d3719..4d1046a219e 100644 ---- a/grub-core/kern/emu/mm.c -+++ b/grub-core/kern/emu/mm.c -@@ -60,7 +60,8 @@ grub_zalloc (grub_size_t size) - void - grub_free (void *ptr) - { -- free (ptr); -+ if (ptr) -+ free (ptr); - } - - void * diff --git a/0248-efi-fix-some-malformed-device-path-arithmetic-errors.patch b/0248-efi-fix-some-malformed-device-path-arithmetic-errors.patch deleted file mode 100644 index a18412f..0000000 --- a/0248-efi-fix-some-malformed-device-path-arithmetic-errors.patch +++ /dev/null @@ -1,248 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Sun, 19 Jul 2020 16:53:27 -0400 -Subject: [PATCH] efi: fix some malformed device path arithmetic errors. - -Several places we take the length of a device path and subtract 4 from -it, without ever checking that it's >= 4. There are also cases where -this kind of malformation will result in unpredictable iteration, -including treating the length from one dp node as the type in the next -node. These are all errors, no matter where the data comes from. - -This patch adds a checking macro, GRUB_EFI_DEVICE_PATH_VALID(), which -can be used in several places, and makes GRUB_EFI_NEXT_DEVICE_PATH() -return NULL and GRUB_EFI_END_ENTIRE_DEVICE_PATH() evaluate as true when -the length is too small. Additionally, it makes several places in the -code check for and return errors in these cases. - -Signed-off-by: Peter Jones -Upstream-commit-id: 23e68a83990 ---- - grub-core/kern/efi/efi.c | 67 ++++++++++++++++++++++++++++++++------ - grub-core/loader/efi/chainloader.c | 19 +++++++++-- - grub-core/loader/i386/xnu.c | 9 ++--- - include/grub/efi/api.h | 14 +++++--- - 4 files changed, 88 insertions(+), 21 deletions(-) - -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index ab133fecce0..8c09e60987d 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -350,7 +350,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) - - dp = dp0; - -- while (1) -+ while (dp) - { - grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp); - grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp); -@@ -360,9 +360,15 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) - if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE - && subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE) - { -- grub_efi_uint16_t len; -- len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4) -- / sizeof (grub_efi_char16_t)); -+ grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp); -+ -+ if (len < 4) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, -+ "malformed EFI Device Path node has length=%d", len); -+ return NULL; -+ } -+ len = (len - 4) / sizeof (grub_efi_char16_t); - filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 2; - } - -@@ -378,7 +384,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) - if (!name) - return NULL; - -- while (1) -+ while (dp) - { - grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp); - grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp); -@@ -394,8 +400,15 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) - - *p++ = '/'; - -- len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4) -- / sizeof (grub_efi_char16_t)); -+ len = GRUB_EFI_DEVICE_PATH_LENGTH (dp); -+ if (len < 4) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, -+ "malformed EFI Device Path node has length=%d", len); -+ return NULL; -+ } -+ -+ len = (len - 4) / sizeof (grub_efi_char16_t); - fp = (grub_efi_file_path_device_path_t *) dp; - /* According to EFI spec Path Name is NULL terminated */ - while (len > 0 && fp->path_name[len - 1] == 0) -@@ -470,7 +483,26 @@ grub_efi_duplicate_device_path (const grub_efi_device_path_t *dp) - ; - p = GRUB_EFI_NEXT_DEVICE_PATH (p)) - { -- total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p); -+ grub_size_t len = GRUB_EFI_DEVICE_PATH_LENGTH (p); -+ -+ /* -+ * In the event that we find a node that's completely garbage, for -+ * example if we get to 0x7f 0x01 0x02 0x00 ... (EndInstance with a size -+ * of 2), GRUB_EFI_END_ENTIRE_DEVICE_PATH() will be true and -+ * GRUB_EFI_NEXT_DEVICE_PATH() will return NULL, so we won't continue, -+ * and neither should our consumers, but there won't be any error raised -+ * even though the device path is junk. -+ * -+ * This keeps us from passing junk down back to our caller. -+ */ -+ if (len < 4) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, -+ "malformed EFI Device Path node has length=%d", len); -+ return NULL; -+ } -+ -+ total_size += len; - if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p)) - break; - } -@@ -515,7 +547,7 @@ dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor) - void - grub_efi_print_device_path (grub_efi_device_path_t *dp) - { -- while (1) -+ while (GRUB_EFI_DEVICE_PATH_VALID (dp)) - { - grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp); - grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp); -@@ -987,7 +1019,11 @@ grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1, - /* Return non-zero. */ - return 1; - -- while (1) -+ if (dp1 == dp2) -+ return 0; -+ -+ while (GRUB_EFI_DEVICE_PATH_VALID (dp1) -+ && GRUB_EFI_DEVICE_PATH_VALID (dp2)) - { - grub_efi_uint8_t type1, type2; - grub_efi_uint8_t subtype1, subtype2; -@@ -1023,5 +1059,16 @@ grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1, - dp2 = (grub_efi_device_path_t *) ((char *) dp2 + len2); - } - -+ /* -+ * There's no "right" answer here, but we probably don't want to call a valid -+ * dp and an invalid dp equal, so pick one way or the other. -+ */ -+ if (GRUB_EFI_DEVICE_PATH_VALID (dp1) && -+ !GRUB_EFI_DEVICE_PATH_VALID (dp2)) -+ return 1; -+ else if (!GRUB_EFI_DEVICE_PATH_VALID (dp1) && -+ GRUB_EFI_DEVICE_PATH_VALID (dp2)) -+ return -1; -+ - return 0; - } -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 736505173cb..5f7c6cfe105 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -125,6 +125,12 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, - fp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE; - fp->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE; - -+ if (!GRUB_EFI_DEVICE_PATH_VALID ((grub_efi_device_path_t *)fp)) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, "EFI Device Path is invalid"); -+ return; -+ } -+ - path_name = grub_calloc (len, GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name)); - if (!path_name) - return; -@@ -165,9 +171,18 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) - - size = 0; - d = dp; -- while (1) -+ while (d) - { -- size += GRUB_EFI_DEVICE_PATH_LENGTH (d); -+ grub_size_t len = GRUB_EFI_DEVICE_PATH_LENGTH (d); -+ -+ if (len < 4) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, -+ "malformed EFI Device Path node has length=%d", len); -+ return NULL; -+ } -+ -+ size += len; - if ((GRUB_EFI_END_ENTIRE_DEVICE_PATH (d))) - break; - d = GRUB_EFI_NEXT_DEVICE_PATH (d); -diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c -index e9e11925972..a7009360732 100644 ---- a/grub-core/loader/i386/xnu.c -+++ b/grub-core/loader/i386/xnu.c -@@ -515,14 +515,15 @@ grub_cmd_devprop_load (grub_command_t cmd __attribute__ ((unused)), - - devhead = buf; - buf = devhead + 1; -- dpstart = buf; -+ dp = dpstart = buf; - -- do -+ while (GRUB_EFI_DEVICE_PATH_VALID (dp) && buf < bufend) - { -- dp = buf; - buf = (char *) buf + GRUB_EFI_DEVICE_PATH_LENGTH (dp); -+ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp)) -+ break; -+ dp = buf; - } -- while (!GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp) && buf < bufend); - - dev = grub_xnu_devprop_add_device (dpstart, (char *) buf - - (char *) dpstart); -diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index dec7b06083e..fc8a564e94d 100644 ---- a/include/grub/efi/api.h -+++ b/include/grub/efi/api.h -@@ -666,6 +666,7 @@ typedef struct grub_efi_device_path grub_efi_device_path_protocol_t; - #define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f) - #define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype) - #define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length) -+#define GRUB_EFI_DEVICE_PATH_VALID(dp) ((dp) != NULL && GRUB_EFI_DEVICE_PATH_LENGTH (dp) >= 4) - - /* The End of Device Path nodes. */ - #define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f) -@@ -674,13 +675,16 @@ typedef struct grub_efi_device_path grub_efi_device_path_protocol_t; - #define GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE 0x01 - - #define GRUB_EFI_END_ENTIRE_DEVICE_PATH(dp) \ -- (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \ -- && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \ -- == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)) -+ (!GRUB_EFI_DEVICE_PATH_VALID (dp) || \ -+ (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \ -+ && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \ -+ == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE))) - - #define GRUB_EFI_NEXT_DEVICE_PATH(dp) \ -- ((grub_efi_device_path_t *) ((char *) (dp) \ -- + GRUB_EFI_DEVICE_PATH_LENGTH (dp))) -+ (GRUB_EFI_DEVICE_PATH_VALID (dp) \ -+ ? ((grub_efi_device_path_t *) \ -+ ((char *) (dp) + GRUB_EFI_DEVICE_PATH_LENGTH (dp))) \ -+ : NULL) - - /* Hardware Device Path. */ - #define GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE 1 diff --git a/0249-Fix-a-regression-caused-by-efi-fix-some-malformed-de.patch b/0249-Fix-a-regression-caused-by-efi-fix-some-malformed-de.patch deleted file mode 100644 index 1bccfd6..0000000 --- a/0249-Fix-a-regression-caused-by-efi-fix-some-malformed-de.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Chris Coulson -Date: Wed, 22 Jul 2020 17:06:04 +0100 -Subject: [PATCH] Fix a regression caused by "efi: fix some malformed device - path arithmetic errors" - -This commit introduced a bogus check inside copy_file_path to -determine whether the destination grub_efi_file_path_device_path_t -was valid before anything was copied to it. Depending on the -contents of the heap buffer, this check could fail which would -result in copy_file_path returning early. - -Without any error propagated to the caller, make_file_path would -then try to advance the invalid device path node with -GRUB_EFI_NEXT_DEVICE_PATH, which would also fail, returning a NULL -pointer that would subsequently be dereferenced. - -Remove the bogus check, and also propagate errors from copy_file_path. ---- - grub-core/loader/efi/chainloader.c | 25 +++++++++++++------------ - 1 file changed, 13 insertions(+), 12 deletions(-) - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 5f7c6cfe105..3dfa41bb49d 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -115,7 +115,7 @@ grub_chainloader_boot (void) - return grub_errno; - } - --static void -+static grub_err_t - copy_file_path (grub_efi_file_path_device_path_t *fp, - const char *str, grub_efi_uint16_t len) - { -@@ -125,15 +125,9 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, - fp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE; - fp->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE; - -- if (!GRUB_EFI_DEVICE_PATH_VALID ((grub_efi_device_path_t *)fp)) -- { -- grub_error (GRUB_ERR_BAD_ARGUMENT, "EFI Device Path is invalid"); -- return; -- } -- - path_name = grub_calloc (len, GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name)); - if (!path_name) -- return; -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed to allocate path buffer"); - - size = grub_utf8_to_utf16 (path_name, len * GRUB_MAX_UTF16_PER_UTF8, - (const grub_uint8_t *) str, len, 0); -@@ -146,6 +140,7 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, - fp->path_name[size++] = '\0'; - fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp); - grub_free (path_name); -+ return GRUB_ERR_NONE; - } - - static grub_efi_device_path_t * -@@ -203,13 +198,19 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) - /* Fill the file path for the directory. */ - d = (grub_efi_device_path_t *) ((char *) file_path - + ((char *) d - (char *) dp)); -- copy_file_path ((grub_efi_file_path_device_path_t *) d, -- dir_start, dir_end - dir_start); -+ if (copy_file_path ((grub_efi_file_path_device_path_t *) d, -+ dir_start, dir_end - dir_start) != GRUB_ERR_NONE) -+ { -+ fail: -+ grub_free (file_path); -+ return 0; -+ } - - /* Fill the file path for the file. */ - d = GRUB_EFI_NEXT_DEVICE_PATH (d); -- copy_file_path ((grub_efi_file_path_device_path_t *) d, -- dir_end + 1, grub_strlen (dir_end + 1)); -+ if (copy_file_path ((grub_efi_file_path_device_path_t *) d, -+ dir_end + 1, grub_strlen (dir_end + 1)) != GRUB_ERR_NONE) -+ goto fail; - - /* Fill the end of device path nodes. */ - d = GRUB_EFI_NEXT_DEVICE_PATH (d); diff --git a/0250-efi-Fix-use-after-free-in-halt-reboot-path.patch b/0250-efi-Fix-use-after-free-in-halt-reboot-path.patch deleted file mode 100644 index b0d5289..0000000 --- a/0250-efi-Fix-use-after-free-in-halt-reboot-path.patch +++ /dev/null @@ -1,162 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexey Makhalov -Date: Mon, 20 Jul 2020 23:03:05 +0000 -Subject: [PATCH] efi: Fix use-after-free in halt/reboot path - -commit 92bfc33db984 ("efi: Free malloc regions on exit") -introduced memory freeing in grub_efi_fini(), which is -used not only by exit path but by halt/reboot one as well. -As result of memory freeing, code and data regions used by -modules, such as halt, reboot, acpi (used by halt) also got -freed. After return to module code, CPU executes, filled -by UEFI firmware (tested with edk2), 0xAFAFAFAF pattern as -a code. Which leads to #UD exception later. - -grub> halt -!!!! X64 Exception Type - 06(#UD - Invalid Opcode) CPU Apic ID - 00000000 !!!! -RIP - 0000000003F4EC28, CS - 0000000000000038, RFLAGS - 0000000000200246 -RAX - 0000000000000000, RCX - 00000000061DA188, RDX - 0A74C0854DC35D41 -RBX - 0000000003E10E08, RSP - 0000000007F0F860, RBP - 0000000000000000 -RSI - 00000000064DB768, RDI - 000000000832C5C3 -R8 - 0000000000000002, R9 - 0000000000000000, R10 - 00000000061E2E52 -R11 - 0000000000000020, R12 - 0000000003EE5C1F, R13 - 00000000061E0FF4 -R14 - 0000000003E10D80, R15 - 00000000061E2F60 -DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030 -GS - 0000000000000030, SS - 0000000000000030 -CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 0000000007C01000 -CR4 - 0000000000000668, CR8 - 0000000000000000 -DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000 -DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400 -GDTR - 00000000079EEA98 0000000000000047, LDTR - 0000000000000000 -IDTR - 0000000007598018 0000000000000FFF, TR - 0000000000000000 -FXSAVE_STATE - 0000000007F0F4C0 - -Proposal here is to continue to free allocated memory for -exit boot services path but keep it for halt/reboot path -as it won't be much security concern here. -Introduced GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY -loader flag to be used by efi halt/reboot path. - -Signed-off-by: Alexey Makhalov -Reviewed-by: Darren Kenny ---- - grub-core/kern/arm/efi/init.c | 3 +++ - grub-core/kern/arm64/efi/init.c | 3 +++ - grub-core/kern/efi/efi.c | 3 ++- - grub-core/kern/efi/init.c | 1 - - grub-core/kern/i386/efi/init.c | 9 +++++++-- - grub-core/kern/ia64/efi/init.c | 9 +++++++-- - grub-core/lib/efi/halt.c | 3 ++- - include/grub/loader.h | 1 + - 8 files changed, 25 insertions(+), 7 deletions(-) - -diff --git a/grub-core/kern/arm/efi/init.c b/grub-core/kern/arm/efi/init.c -index 06df60e2f0e..40c3b467fc6 100644 ---- a/grub-core/kern/arm/efi/init.c -+++ b/grub-core/kern/arm/efi/init.c -@@ -71,4 +71,7 @@ grub_machine_fini (int flags) - efi_call_1 (b->close_event, tmr_evt); - - grub_efi_fini (); -+ -+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) -+ grub_efi_memory_fini (); - } -diff --git a/grub-core/kern/arm64/efi/init.c b/grub-core/kern/arm64/efi/init.c -index 6224999ec9c..5010caefd66 100644 ---- a/grub-core/kern/arm64/efi/init.c -+++ b/grub-core/kern/arm64/efi/init.c -@@ -57,4 +57,7 @@ grub_machine_fini (int flags) - return; - - grub_efi_fini (); -+ -+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) -+ grub_efi_memory_fini (); - } -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 8c09e60987d..5ee739d51ae 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -157,7 +157,8 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) - void - grub_reboot (void) - { -- grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); -+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN | -+ GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY); - efi_call_4 (grub_efi_system_table->runtime_services->reset_system, - GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL); - for (;;) ; -diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index d1afa3af11e..2ffb5205dda 100644 ---- a/grub-core/kern/efi/init.c -+++ b/grub-core/kern/efi/init.c -@@ -131,5 +131,4 @@ grub_efi_fini (void) - { - grub_efidisk_fini (); - grub_console_fini (); -- grub_efi_memory_fini (); - } -diff --git a/grub-core/kern/i386/efi/init.c b/grub-core/kern/i386/efi/init.c -index da499aba04e..deb2eacd8d8 100644 ---- a/grub-core/kern/i386/efi/init.c -+++ b/grub-core/kern/i386/efi/init.c -@@ -39,6 +39,11 @@ grub_machine_init (void) - void - grub_machine_fini (int flags) - { -- if (flags & GRUB_LOADER_FLAG_NORETURN) -- grub_efi_fini (); -+ if (!(flags & GRUB_LOADER_FLAG_NORETURN)) -+ return; -+ -+ grub_efi_fini (); -+ -+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) -+ grub_efi_memory_fini (); - } -diff --git a/grub-core/kern/ia64/efi/init.c b/grub-core/kern/ia64/efi/init.c -index b5ecbd09121..f1965571b1d 100644 ---- a/grub-core/kern/ia64/efi/init.c -+++ b/grub-core/kern/ia64/efi/init.c -@@ -70,6 +70,11 @@ grub_machine_init (void) - void - grub_machine_fini (int flags) - { -- if (flags & GRUB_LOADER_FLAG_NORETURN) -- grub_efi_fini (); -+ if (!(flags & GRUB_LOADER_FLAG_NORETURN)) -+ return; -+ -+ grub_efi_fini (); -+ -+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) -+ grub_efi_memory_fini (); - } -diff --git a/grub-core/lib/efi/halt.c b/grub-core/lib/efi/halt.c -index 5859f0498a8..29d41364168 100644 ---- a/grub-core/lib/efi/halt.c -+++ b/grub-core/lib/efi/halt.c -@@ -28,7 +28,8 @@ - void - grub_halt (void) - { -- grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); -+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN | -+ GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY); - #if !defined(__ia64__) && !defined(__arm__) && !defined(__aarch64__) && \ - !defined(__riscv) - grub_acpi_halt (); -diff --git a/include/grub/loader.h b/include/grub/loader.h -index 7f82a499fd9..b208642821b 100644 ---- a/include/grub/loader.h -+++ b/include/grub/loader.h -@@ -33,6 +33,7 @@ enum - { - GRUB_LOADER_FLAG_NORETURN = 1, - GRUB_LOADER_FLAG_PXE_NOT_UNLOAD = 2, -+ GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY = 4, - }; - - void EXPORT_FUNC (grub_loader_set) (grub_err_t (*boot) (void), diff --git a/0255-efi-Fix-use-after-free-in-halt-reboot-path.patch b/0255-efi-Fix-use-after-free-in-halt-reboot-path.patch deleted file mode 100644 index 93efaf6..0000000 --- a/0255-efi-Fix-use-after-free-in-halt-reboot-path.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Alexey Makhalov -Date: Mon, 20 Jul 2020 23:03:05 +0000 -Subject: [PATCH] efi: Fix use-after-free in halt/reboot path - -commit 92bfc33db984 ("efi: Free malloc regions on exit") -introduced memory freeing in grub_efi_fini(), which is -used not only by exit path but by halt/reboot one as well. -As result of memory freeing, code and data regions used by -modules, such as halt, reboot, acpi (used by halt) also got -freed. After return to module code, CPU executes, filled -by UEFI firmware (tested with edk2), 0xAFAFAFAF pattern as -a code. Which leads to #UD exception later. - -grub> halt -!!!! X64 Exception Type - 06(#UD - Invalid Opcode) CPU Apic ID - 00000000 !!!! -RIP - 0000000003F4EC28, CS - 0000000000000038, RFLAGS - 0000000000200246 -RAX - 0000000000000000, RCX - 00000000061DA188, RDX - 0A74C0854DC35D41 -RBX - 0000000003E10E08, RSP - 0000000007F0F860, RBP - 0000000000000000 -RSI - 00000000064DB768, RDI - 000000000832C5C3 -R8 - 0000000000000002, R9 - 0000000000000000, R10 - 00000000061E2E52 -R11 - 0000000000000020, R12 - 0000000003EE5C1F, R13 - 00000000061E0FF4 -R14 - 0000000003E10D80, R15 - 00000000061E2F60 -DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030 -GS - 0000000000000030, SS - 0000000000000030 -CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 0000000007C01000 -CR4 - 0000000000000668, CR8 - 0000000000000000 -DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000 -DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400 -GDTR - 00000000079EEA98 0000000000000047, LDTR - 0000000000000000 -IDTR - 0000000007598018 0000000000000FFF, TR - 0000000000000000 -FXSAVE_STATE - 0000000007F0F4C0 - -Proposal here is to continue to free allocated memory for -exit boot services path but keep it for halt/reboot path -as it won't be much security concern here. -Introduced GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY -loader flag to be used by efi halt/reboot path. - -Signed-off-by: Alexey Makhalov -Reviewed-by: Darren Kenny ---- - grub-core/kern/riscv/efi/init.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/grub-core/kern/riscv/efi/init.c b/grub-core/kern/riscv/efi/init.c -index 7eb1969d0b0..38795fe6741 100644 ---- a/grub-core/kern/riscv/efi/init.c -+++ b/grub-core/kern/riscv/efi/init.c -@@ -73,4 +73,7 @@ grub_machine_fini (int flags) - return; - - grub_efi_fini (); -+ -+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) -+ grub_efi_memory_fini (); - } diff --git a/0256-linux-loader-avoid-overflow-on-initrd-size-calculati.patch b/0256-linux-loader-avoid-overflow-on-initrd-size-calculati.patch deleted file mode 100644 index 51f39e5..0000000 --- a/0256-linux-loader-avoid-overflow-on-initrd-size-calculati.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 24 Jul 2020 13:57:27 -0400 -Subject: [PATCH] linux loader: avoid overflow on initrd size calculation - -Signed-off-by: Peter Jones ---- - grub-core/loader/linux.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c -index 471b214d6c3..25624ebc114 100644 ---- a/grub-core/loader/linux.c -+++ b/grub-core/loader/linux.c -@@ -151,8 +151,8 @@ grub_initrd_init (int argc, char *argv[], - initrd_ctx->nfiles = 0; - initrd_ctx->components = 0; - -- initrd_ctx->components = grub_zalloc (argc -- * sizeof (initrd_ctx->components[0])); -+ initrd_ctx->components = grub_calloc (argc, -+ sizeof (initrd_ctx->components[0])); - if (!initrd_ctx->components) - return grub_errno; - diff --git a/0258-linux-Fix-integer-overflows-in-initrd-size-handling.patch b/0258-linux-Fix-integer-overflows-in-initrd-size-handling.patch deleted file mode 100644 index b784faa..0000000 --- a/0258-linux-Fix-integer-overflows-in-initrd-size-handling.patch +++ /dev/null @@ -1,166 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Colin Watson -Date: Sat, 25 Jul 2020 12:15:37 +0100 -Subject: [PATCH] linux: Fix integer overflows in initrd size handling - -These could be triggered by a crafted filesystem with very large files. - -Fixes: CVE-2020-15707 - -Signed-off-by: Colin Watson -Reviewed-by: Jan Setje-Eilers ---- - grub-core/loader/linux.c | 75 +++++++++++++++++++++++++++++++++++------------- - 1 file changed, 55 insertions(+), 20 deletions(-) - -diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c -index 25624ebc114..1af142f5760 100644 ---- a/grub-core/loader/linux.c -+++ b/grub-core/loader/linux.c -@@ -4,6 +4,8 @@ - #include - #include - #include -+#include -+#include - - struct newc_head - { -@@ -98,13 +100,13 @@ free_dir (struct dir *root) - grub_free (root); - } - --static grub_size_t -+static grub_err_t - insert_dir (const char *name, struct dir **root, -- grub_uint8_t *ptr) -+ grub_uint8_t *ptr, grub_size_t *size) - { - struct dir *cur, **head = root; - const char *cb, *ce = name; -- grub_size_t size = 0; -+ *size = 0; - while (1) - { - for (cb = ce; *cb == '/'; cb++); -@@ -130,14 +132,22 @@ insert_dir (const char *name, struct dir **root, - ptr = make_header (ptr, name, ce - name, - 040777, 0); - } -- size += ALIGN_UP ((ce - (char *) name) -- + sizeof (struct newc_head), 4); -+ if (grub_add (*size, -+ ALIGN_UP ((ce - (char *) name) -+ + sizeof (struct newc_head), 4), -+ size)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); -+ grub_free (n->name); -+ grub_free (n); -+ return grub_errno; -+ } - *head = n; - cur = n; - } - root = &cur->next; - } -- return size; -+ return GRUB_ERR_NONE; - } - - grub_err_t -@@ -173,26 +183,33 @@ grub_initrd_init (int argc, char *argv[], - eptr = grub_strchr (ptr, ':'); - if (eptr) - { -+ grub_size_t dir_size, name_len; -+ - initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr); -- if (!initrd_ctx->components[i].newc_name) -+ if (!initrd_ctx->components[i].newc_name || -+ insert_dir (initrd_ctx->components[i].newc_name, &root, 0, -+ &dir_size)) - { - grub_initrd_close (initrd_ctx); - return grub_errno; - } -- initrd_ctx->size -- += ALIGN_UP (sizeof (struct newc_head) -- + grub_strlen (initrd_ctx->components[i].newc_name), -- 4); -- initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name, -- &root, 0); -+ name_len = grub_strlen (initrd_ctx->components[i].newc_name); -+ if (grub_add (initrd_ctx->size, -+ ALIGN_UP (sizeof (struct newc_head) + name_len, 4), -+ &initrd_ctx->size) || -+ grub_add (initrd_ctx->size, dir_size, &initrd_ctx->size)) -+ goto overflow; - newc = 1; - fname = eptr + 1; - } - } - else if (newc) - { -- initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head) -- + sizeof ("TRAILER!!!") - 1, 4); -+ if (grub_add (initrd_ctx->size, -+ ALIGN_UP (sizeof (struct newc_head) -+ + sizeof ("TRAILER!!!") - 1, 4), -+ &initrd_ctx->size)) -+ goto overflow; - free_dir (root); - root = 0; - newc = 0; -@@ -208,19 +225,29 @@ grub_initrd_init (int argc, char *argv[], - initrd_ctx->nfiles++; - initrd_ctx->components[i].size - = grub_file_size (initrd_ctx->components[i].file); -- initrd_ctx->size += initrd_ctx->components[i].size; -+ if (grub_add (initrd_ctx->size, initrd_ctx->components[i].size, -+ &initrd_ctx->size)) -+ goto overflow; - } - - if (newc) - { - initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4); -- initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head) -- + sizeof ("TRAILER!!!") - 1, 4); -+ if (grub_add (initrd_ctx->size, -+ ALIGN_UP (sizeof (struct newc_head) -+ + sizeof ("TRAILER!!!") - 1, 4), -+ &initrd_ctx->size)) -+ goto overflow; - free_dir (root); - root = 0; - } - - return GRUB_ERR_NONE; -+ -+overflow: -+ free_dir (root); -+ grub_initrd_close (initrd_ctx); -+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); - } - - grub_size_t -@@ -261,8 +288,16 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, - - if (initrd_ctx->components[i].newc_name) - { -- ptr += insert_dir (initrd_ctx->components[i].newc_name, -- &root, ptr); -+ grub_size_t dir_size; -+ -+ if (insert_dir (initrd_ctx->components[i].newc_name, &root, ptr, -+ &dir_size)) -+ { -+ free_dir (root); -+ grub_initrd_close (initrd_ctx); -+ return grub_errno; -+ } -+ ptr += dir_size; - ptr = make_header (ptr, initrd_ctx->components[i].newc_name, - grub_strlen (initrd_ctx->components[i].newc_name), - 0100777, diff --git a/0259-Fix-const-char-pointers-in-grub-core-commands-blscfg.patch b/0259-Fix-const-char-pointers-in-grub-core-commands-blscfg.patch deleted file mode 100644 index 62658d2..0000000 --- a/0259-Fix-const-char-pointers-in-grub-core-commands-blscfg.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 20 Jul 2020 12:24:02 -0400 -Subject: [PATCH] Fix const char ** pointers in grub-core/commands/blscfg.c - -This will need to get folded back in the right place on the next rebase, -but it's before "Make grub_strtol() "end" pointers have safer const -qualifiers" currently, so for now I'm leaving it here instead of merging -it back with the original patch. - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 4ec6504d9a4..e907a6a5d28 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -612,7 +612,7 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) - return list; - } - --static char *field_append(bool is_var, char *buffer, char *start, char *end) -+static char *field_append(bool is_var, char *buffer, const char *start, const char *end) - { - char *tmp = grub_strndup(start, end - start + 1); - const char *field = tmp; -@@ -641,11 +641,11 @@ static char *field_append(bool is_var, char *buffer, char *start, char *end) - return buffer; - } - --static char *expand_val(char *value) -+static char *expand_val(const char *value) - { - char *buffer = NULL; -- char *start = value; -- char *end = value; -+ const char *start = value; -+ const char *end = value; - bool is_var = false; - - if (!value) diff --git a/0265-Fix-const-char-pointers-in-grub-core-net-url.c.patch b/0265-Fix-const-char-pointers-in-grub-core-net-url.c.patch deleted file mode 100644 index e3d1be4..0000000 --- a/0265-Fix-const-char-pointers-in-grub-core-net-url.c.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 20 Jul 2020 12:24:02 -0400 -Subject: [PATCH] Fix const char ** pointers in grub-core/net/url.c - -This will need to get folded back in the right place on the next rebase, -but it's before "Make grub_strtol() "end" pointers have safer const -qualifiers" currently, so for now I'm leaving it here instead of merging -it back with the original patch. - -Signed-off-by: Peter Jones ---- - grub-core/net/url.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/net/url.c b/grub-core/net/url.c -index 146858284cd..d9d2fc9a9dc 100644 ---- a/grub-core/net/url.c -+++ b/grub-core/net/url.c -@@ -235,7 +235,7 @@ extract_http_url_info (char *url, int ssl, - c = *port_end; - *port_end = '\0'; - -- portul = grub_strtoul (port_off, &separator, 10); -+ portul = grub_strtoul (port_off, (const char **)&separator, 10); - *port_end = c; - #ifdef URL_TEST - if (portul == ULONG_MAX && errno == ERANGE) diff --git a/0268-tftp-roll-over-block-counter-to-prevent-timeouts-wit.patch b/0268-tftp-roll-over-block-counter-to-prevent-timeouts-wit.patch deleted file mode 100644 index e7b5c6e..0000000 --- a/0268-tftp-roll-over-block-counter-to-prevent-timeouts-wit.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 24 Aug 2020 14:46:27 +0200 -Subject: [PATCH] tftp: roll over block counter to prevent timeouts with data - packets - -The block number is a 16-bit counter which only allows to fetch -files no bigger than 65535 * blksize. To avoid this limit, the -counter is rolled over. This behavior isn't defined in RFC 1350 -but is handled by many TFTP servers and it's what GRUB was doing -before implicitly due an overflow. - -Fixing that bug led to TFTP timeouts, since GRUB wasn't acking -data packets anymore for files with size bigger than the maximum -mentioned above. Restore the old behavior to prevent this issue. - -Resolves: rhbz#1869335 - -Suggested-by: Peter Jones -Signed-off-by: Javier Martinez Canillas ---- - grub-core/net/tftp.c | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 22badd74316..acbb01c10e7 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -183,8 +183,20 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)), - return GRUB_ERR_NONE; - } - -- /* Ack old/retransmitted block. */ -- if (grub_be_to_cpu16 (tftph->u.data.block) < data->block + 1) -+ /* -+ * Ack old/retransmitted block. -+ * -+ * The block number is a 16-bit counter which only allows to fetch -+ * files no bigger than 65535 * blksize. To avoid this limit, the -+ * counter is rolled over. This behavior isn't defined in RFC 1350 -+ * but is handled by many TFTP servers and it's what GRUB was doing -+ * before implicitly due an overflow. -+ * -+ * Fixing that bug led to TFTP timeouts, since GRUB wasn't acking -+ * data packets anymore for files with size bigger than the maximum -+ * mentioned above. Restore the old behavior to prevent this issue. -+ */ -+ if (grub_be_to_cpu16 (tftph->u.data.block) < ((data->block + 1) & 0xffffu)) - ack (data, grub_be_to_cpu16 (tftph->u.data.block)); - /* Ignore unexpected block. */ - else if (grub_be_to_cpu16 (tftph->u.data.block) > data->block + 1) diff --git a/0278-btrfs-Add-support-for-new-RAID1C34-profiles.patch b/0278-btrfs-Add-support-for-new-RAID1C34-profiles.patch deleted file mode 100644 index d6abc6b..0000000 --- a/0278-btrfs-Add-support-for-new-RAID1C34-profiles.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: David Sterba -Date: Mon, 4 Nov 2019 17:23:22 +0100 -Subject: [PATCH] btrfs: Add support for new RAID1C34 profiles - -New 3- and 4-copy variants of RAID1 were merged into Linux kernel 5.5. -Add the two new profiles to the list of recognized ones. As this builds -on the same code as RAID1, only the redundancy level needs to be -adjusted, the rest is done by the existing code. - -Signed-off-by: David Sterba -Reviewed-by: Daniel Kiper ---- - grub-core/fs/btrfs.c | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 0d8c666aea1..78f5de37b27 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -144,6 +144,8 @@ struct grub_btrfs_chunk_item - #define GRUB_BTRFS_CHUNK_TYPE_RAID10 0x40 - #define GRUB_BTRFS_CHUNK_TYPE_RAID5 0x80 - #define GRUB_BTRFS_CHUNK_TYPE_RAID6 0x100 -+#define GRUB_BTRFS_CHUNK_TYPE_RAID1C3 0x200 -+#define GRUB_BTRFS_CHUNK_TYPE_RAID1C4 0x400 - grub_uint8_t dummy2[0xc]; - grub_uint16_t nstripes; - grub_uint16_t nsubstripes; -@@ -1003,14 +1005,19 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - csize = (stripen + 1) * stripe_length - off; - break; - } -+ case GRUB_BTRFS_CHUNK_TYPE_RAID1C4: -+ redundancy++; -+ /* fall through */ -+ case GRUB_BTRFS_CHUNK_TYPE_RAID1C3: -+ redundancy++; -+ /* fall through */ - case GRUB_BTRFS_CHUNK_TYPE_DUPLICATED: - case GRUB_BTRFS_CHUNK_TYPE_RAID1: - { -- grub_dprintf ("btrfs", "RAID1\n"); -+ grub_dprintf ("btrfs", "RAID1 (copies: %d)\n", ++redundancy); - stripen = 0; - stripe_offset = off; - csize = grub_le_to_cpu64 (chunk->size) - off; -- redundancy = 2; - break; - } - case GRUB_BTRFS_CHUNK_TYPE_RAID0: diff --git a/0279-verifiers-Fix-calling-uninitialized-function-pointer.patch b/0279-verifiers-Fix-calling-uninitialized-function-pointer.patch deleted file mode 100644 index 1f3b040..0000000 --- a/0279-verifiers-Fix-calling-uninitialized-function-pointer.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Michael Chang -Date: Tue, 18 Feb 2020 18:08:18 +0800 -Subject: [PATCH] verifiers: Fix calling uninitialized function pointer - -The necessary check for NULL before use of function ver->close is not -taking place in the failure path. This patch simply adds the missing -check and fixes the problem that GRUB hangs indefinitely after booting -rogue image without valid signature if secure boot is turned on. - -Now it displays like this for booting rogue UEFI image: - - error: bad shim signature - error: you need to load the kernel first - - Press any key to continue... - -and then you can go back to boot menu by pressing any key or after a few -seconds expired. - -Signed-off-by: Michael Chang -Reviewed-by: Javier Martinez Canillas -Reviewed-by: Daniel Kiper ---- - grub-core/commands/verifiers.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c -index 0dde4818267..7b9297cd345 100644 ---- a/grub-core/commands/verifiers.c -+++ b/grub-core/commands/verifiers.c -@@ -196,7 +196,8 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) - return ret; - - fail: -- ver->close (context); -+ if (ver->close) -+ ver->close (context); - fail_noclose: - verified_free (verified); - grub_free (ret); diff --git a/0283-docs-grub-grub-install-is-no-longer-a-shell-script.patch b/0283-docs-grub-grub-install-is-no-longer-a-shell-script.patch deleted file mode 100644 index 7216019..0000000 --- a/0283-docs-grub-grub-install-is-no-longer-a-shell-script.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Sat, 15 Aug 2020 01:00:11 +1000 -Subject: [PATCH] docs/grub: grub-install is no longer a shell script - -Since commit cd46aa6cefab in 2013, grub-install hasn't been a shell -script. The para doesn't really add that much, especially since it's -the user manual, so just drop it. - -(adjust docs: s/grub/grub2) -Signed-off-by: Daniel Axtens ---- - docs/grub.texi | 7 ------- - 1 file changed, 7 deletions(-) - -diff --git a/docs/grub.texi b/docs/grub.texi -index e8bfe7ee7e8..2436c57f598 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -695,13 +695,6 @@ floppy instead of exposing the USB drive as a hard disk (they call it - This install doesn't conflict with standard install as long as they are in - separate directories. - --Note that @command{grub2-install} is actually just a shell script and the --real task is done by other tools such as @command{grub2-mkimage}. Therefore, --you may run those commands directly to install GRUB, without using --@command{grub2-install}. Don't do that, however, unless you are very familiar --with the internals of GRUB. Installing a boot loader on a running OS may be --extremely dangerous. -- - On EFI systems for fixed disk install you have to mount EFI System Partition. - If you mount it at @file{/boot/efi} then you don't need any special arguments: - diff --git a/0284-docs-grub-pubkey-has-been-supported-for-some-time.patch b/0284-docs-grub-pubkey-has-been-supported-for-some-time.patch deleted file mode 100644 index 51a843b..0000000 --- a/0284-docs-grub-pubkey-has-been-supported-for-some-time.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Sat, 15 Aug 2020 02:04:01 +1000 -Subject: [PATCH] docs/grub: --pubkey has been supported for some time - ---pubkey is supported, so we can now document it. - -(adjust docs: s/grub/grub2) -Signed-off-by: Daniel Axtens ---- - docs/grub.texi | 12 +++--------- - 1 file changed, 3 insertions(+), 9 deletions(-) - -diff --git a/docs/grub.texi b/docs/grub.texi -index 2436c57f598..7fc2a62a4f8 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -5732,15 +5732,9 @@ verified with a public key currently trusted by GRUB - validation fails, then file @file{foo} cannot be opened. This failure - may halt or otherwise impact the boot process. - --@comment Unfortunately --pubkey is not yet supported by grub2-install, --@comment but we should not bring up internal detail grub2-mkimage here --@comment in the user guide (as opposed to developer's manual). -- --@comment An initial trusted public key can be embedded within the GRUB --@comment @file{core.img} using the @code{--pubkey} option to --@comment @command{grub2-mkimage} (@pxref{Invoking grub2-install}). Presently it --@comment is necessary to write a custom wrapper around @command{grub2-mkimage} --@comment using the @code{--grub-mkimage} flag to @command{grub2-install}. -+An initial trusted public key can be embedded within the GRUB -+@file{core.img} using the @code{--pubkey} option to -+@command{grub2-install} (@pxref{Invoking grub2-install}). - - GRUB uses GPG-style detached signatures (meaning that a file - @file{foo.sig} will be produced when file @file{foo} is signed), and diff --git a/0286-verifiers-provide-unsafe-module-list.patch b/0286-verifiers-provide-unsafe-module-list.patch deleted file mode 100644 index 1548d3a..0000000 --- a/0286-verifiers-provide-unsafe-module-list.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Wed, 29 Jul 2020 17:46:16 +1000 -Subject: [PATCH] verifiers: provide unsafe module list - -Other verifiers that implement secure boot may want to be able to -use this list and behaviour. - -Upstream, this factors the list out of the shim_lock verifier. -However, that hasn't hit the RHEL8.4 tree yet, so instead -of factoring it out of that we just create it. - -Signed-off-by: Daniel Axtens ---- - grub-core/commands/verifiers.c | 46 ++++++++++++++++++++++++++++++++++++++++++ - include/grub/verify.h | 13 ++++++++++++ - 2 files changed, 59 insertions(+) - -diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c -index 7b9297cd345..4ced984cfed 100644 ---- a/grub-core/commands/verifiers.c -+++ b/grub-core/commands/verifiers.c -@@ -218,6 +218,52 @@ grub_verify_string (char *str, enum grub_verify_string_type type) - return GRUB_ERR_NONE; - } - -+/* List of modules which may allow for verifcation to be bypassed. */ -+static const char *const disabled_mods[] = { "iorw", "memrw", "wrmsr", NULL }; -+ -+/* -+ * Does the module in file `io' allow for the a verifier to be bypassed? -+ * -+ * Returns 1 if so, otherwise 0. -+ */ -+char -+grub_is_dangerous_module (grub_file_t io) -+{ -+ char *b, *e; -+ int i; -+ -+ /* Establish GRUB module name. */ -+ b = grub_strrchr (io->name, '/'); -+ e = grub_strrchr (io->name, '.'); -+ -+ b = b ? (b + 1) : io->name; -+ e = e ? e : io->name + grub_strlen (io->name); -+ e = (e > b) ? e : io->name + grub_strlen (io->name); -+ -+ for (i = 0; disabled_mods[i]; i++) -+ if (!grub_strncmp (b, disabled_mods[i], -+ grub_strlen (b) - grub_strlen (e))) -+ return 1; -+ return 0; -+} -+ -+/* -+ * Is there already an unsafe module in memory? -+ * Returns the name if one is loaded, otherwise NULL. -+ */ -+const char * -+grub_dangerous_module_loaded (void) -+{ -+ int i; -+ -+ for (i = 0; disabled_mods[i]; i++) -+ if (grub_dl_get (disabled_mods[i])) -+ { -+ return disabled_mods[i]; -+ } -+ return NULL; -+} -+ - GRUB_MOD_INIT(verifiers) - { - grub_file_filter_register (GRUB_FILE_FILTER_VERIFY, grub_verifiers_open); -diff --git a/include/grub/verify.h b/include/grub/verify.h -index ea049143368..8c2de132051 100644 ---- a/include/grub/verify.h -+++ b/include/grub/verify.h -@@ -81,4 +81,17 @@ grub_verifier_unregister (struct grub_file_verifier *ver) - grub_err_t - grub_verify_string (char *str, enum grub_verify_string_type type); - -+/* -+ * Does the module in file `io' allow for the a verifier to be bypassed? -+ * -+ * Returns 1 if so, otherwise 0. -+ */ -+char grub_is_dangerous_module (grub_file_t io); -+ -+/* -+ * Is there already an unsafe module in memory? -+ * Returns the name if one is loaded, otherwise NULL. -+ */ -+const char *grub_dangerous_module_loaded (void); -+ - #endif /* ! GRUB_VERIFY_HEADER */ diff --git a/0301-ieee1275-link-appended-signature-enforcement-to-ibm-.patch b/0301-ieee1275-link-appended-signature-enforcement-to-ibm-.patch deleted file mode 100644 index 76c716b..0000000 --- a/0301-ieee1275-link-appended-signature-enforcement-to-ibm-.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 28 Sep 2020 11:11:17 +1000 -Subject: [PATCH] ieee1275: link appended-signature enforcement to - /ibm,secure-boot - -If the 'ibm,secure-boot' property of the root node is 2 or greater, -require that the kernel pass appended-signature verification. - -Do not consider the presence of a certificate to enforce verification. - -Signed-off-by: Daniel Axtens ---- - grub-core/commands/appendedsig/appendedsig.c | 44 +++++++++++++++++++++------- - grub-core/kern/ieee1275/init.c | 26 ++++++++++++++++ - 2 files changed, 60 insertions(+), 10 deletions(-) - -diff --git a/grub-core/commands/appendedsig/appendedsig.c b/grub-core/commands/appendedsig/appendedsig.c -index 1fbc942254a..6efe58ce8b2 100644 ---- a/grub-core/commands/appendedsig/appendedsig.c -+++ b/grub-core/commands/appendedsig/appendedsig.c -@@ -95,10 +95,24 @@ static char * - grub_env_write_sec (struct grub_env_var *var __attribute__((unused)), - const char *val) - { -+ if (check_sigs == 2) -+ return grub_strdup ("forced"); - check_sigs = (*val == '1') || (*val == 'e'); - return grub_strdup (check_sigs ? "enforce" : "no"); - } - -+static const char * -+grub_env_read_sec (struct grub_env_var *var __attribute__ ((unused)), -+ const char *val __attribute__ ((unused))) -+{ -+ if (check_sigs == 2) -+ return "forced"; -+ else if (check_sigs == 1) -+ return "enforce"; -+ else -+ return "no"; -+} -+ - static grub_err_t - read_cert_from_file (grub_file_t f, struct x509_certificate *certificate) - { -@@ -552,14 +566,20 @@ GRUB_MOD_INIT (appendedsig) - val = grub_env_get ("check_appended_signatures"); - grub_dprintf ("appendedsig", "check_appended_signatures='%s'\n", val); - -- if (val && (val[0] == '1' || val[0] == 'e')) -- check_sigs = 1; -- else -- check_sigs = 0; -+ if (val) -+ { -+ if (val[0] == '2' || val[0] == 'f') -+ check_sigs = 2; -+ else if (val[0] == '1' || val[0] == 'e') -+ check_sigs = 1; -+ else -+ check_sigs = 0; -+ } - - grub_trusted_key = NULL; - -- grub_register_variable_hook ("check_appended_signatures", 0, -+ grub_register_variable_hook ("check_appended_signatures", -+ grub_env_read_sec, - grub_env_write_sec); - grub_env_export ("check_appended_signatures"); - -@@ -603,11 +623,15 @@ GRUB_MOD_INIT (appendedsig) - grub_trusted_key = pk; - } - -- if (!val || val[0] == '\0') -- { -- grub_env_set ("check_appended_signatures", -- grub_trusted_key ? "enforce" : "no"); -- } -+ /* -+ * When controlled by ibm,secure-boot, we don't want the presence of -+ * a certificate to enforce secure boot. -+ * if (!val || val[0] == '\0') -+ * { -+ * grub_env_set ("check_appended_signatures", -+ * grub_trusted_key ? "enforce" : "no"); -+ * } -+ */ - - cmd_trust = - grub_register_command ("trust_certificate", grub_cmd_trust, -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 937c1bc44cb..5df2e0efae7 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -271,6 +271,30 @@ grub_parse_cmdline (void) - } - } - -+static void -+grub_get_ieee1275_secure_boot (void) -+{ -+ grub_ieee1275_phandle_t root; -+ int rc; -+ grub_uint32_t is_sb; -+ -+ grub_ieee1275_finddevice ("/", &root); -+ -+ rc = grub_ieee1275_get_integer_property (root, "ibm,secure-boot", &is_sb, -+ sizeof (is_sb), 0); -+ -+ /* ibm,secure-boot: -+ * 0 - disabled -+ * 1 - audit -+ * 2 - enforce -+ * 3 - enforce + OS-specific behaviour -+ * -+ * We only support enforce. -+ */ -+ if (rc >= 0 && is_sb >= 2) -+ grub_env_set("check_appended_signatures", "forced"); -+} -+ - grub_addr_t grub_modbase; - - void -@@ -296,6 +320,8 @@ grub_machine_init (void) - #else - grub_install_get_time_ms (grub_rtc_get_time_ms); - #endif -+ -+ grub_get_ieee1275_secure_boot (); - } - - void diff --git a/0304-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch b/0304-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch deleted file mode 100644 index 79c805f..0000000 --- a/0304-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 10 Mar 2021 12:50:15 +0100 -Subject: [PATCH] 10_linux.in: Check if petitboot sysfs has a valid version - -The script assumes that the petitboot sysfs entry contains a valid version -number, but this is not always the case. For example, on a Talos II system -a user reported that contained the following value: - -$ cat /sys/firmware/devicetree/base/ibm,firmware-versions/petitboot -0ed84c0-p94177c1 - -This lead to the script wrongly trying to compare these hashes as if they -were integers values, which caused the following error when re-generating -the GRUB configuration file: - -/etc/grub.d/10_linux: line 234: test: 0ed84c0-p94177c1: integer expression expected -/etc/grub.d/10_linux: line 235: test: 0ed84c0-p94177c1: integer expression expected - -Check that the major and minor values are integers before attempting to do -the comparison. If these aren't numbers, then generate the menu with a set -of menuentry commands, since there's no way to know the petitboot version. - -Resolves: rhbz#1921479 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 19 ++++++++++++------- - 1 file changed, 12 insertions(+), 7 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index e61b6c94f11..b9426eb2e2e 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -223,20 +223,25 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - arch="$(uname -m)" - if [ "x${arch}" = "xppc64le" ] && [ -d /sys/firmware/opal ]; then - -+ BLS_POPULATE_MENU="true" - petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" - - if test -e ${petitboot_path}; then - read -r -d '' petitboot_version < ${petitboot_path} - petitboot_version="$(echo ${petitboot_version//v})" -- major_version="$(echo ${petitboot_version} | cut -d . -f1)" -- minor_version="$(echo ${petitboot_version} | cut -d . -f2)" - -- if test -z ${petitboot_version} || test ${major_version} -lt 1 || \ -- test ${major_version} -eq 1 -a ${minor_version} -lt 8; then -- BLS_POPULATE_MENU="true" -+ if test -n ${petitboot_version}; then -+ major_version="$(echo ${petitboot_version} | cut -d . -f1)" -+ minor_version="$(echo ${petitboot_version} | cut -d . -f2)" -+ -+ re='^[0-9]+$' -+ if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] && -+ ([[ ${major_version} -gt 1 ]] || -+ [[ ${major_version} -eq 1 && -+ ${minor_version} -ge 8 ]]); then -+ BLS_POPULATE_MENU="false" -+ fi - fi -- else -- BLS_POPULATE_MENU="true" - fi - fi - diff --git a/bootstrap.conf b/bootstrap.conf index 988dda0..6b043fc 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -23,6 +23,7 @@ GNULIB_REVISION=d271f868a8df9bbec29049d01e056481b7a1a263 # directly. gnulib_modules=" argp + base64 error fnmatch getdelim @@ -78,10 +79,19 @@ cp -a INSTALL INSTALL.grub bootstrap_post_import_hook () { set -e - for patchname in fix-null-deref fix-width no-abort; do + for patchname in fix-base64 fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \ + fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do patch -d grub-core/lib/gnulib -p2 \ < "grub-core/lib/gnulib-patches/$patchname.patch" done + for patchname in \ + 0001-Support-POTFILES-shell \ + 0002-Handle-gettext_printf-shell-function \ + 0003-Make-msgfmt-output-in-little-endian \ + 0004-Use-SHELL-rather-than-bin-sh; do + patch -d po -p3 \ + < "po/gettext-patches/$patchname.patch" + done FROM_BOOTSTRAP=1 ./autogen.sh set +e # bootstrap expects this } diff --git a/gitignore b/gitignore index 819cd18..f6a1bd0 100644 --- a/gitignore +++ b/gitignore @@ -1,237 +1,277 @@ -*~ -00_header -10_* -20_linux_xen -30_os-prober -40_custom -41_custom +# +# Ignore patterns in this directory and all subdirectories. +# *.1 *.8 -ABOUT-NLS -aclocal.m4 -ahci_test -ascii.bitmaps -ascii.h -autom4te.cache -build-aux -build-grub-gen-asciih -build-grub-gen-widthspec -build-grub-mkfont -cdboot_test -cmp_test -config.cache -config.guess -config.h -config-util.h -config-util.h.in -config.log -config.status -config.sub -configure -core_compress_test -DISTLIST -docs/*.info -docs/stamp-vti -docs/version.texi -ehci_test -example_grub_script_test -example_scripted_test -example_unit_test +*.a *.exec *.exec.exe -fddboot_test -genkernsyms.sh -gensymlist.sh -gentrigtables -gentrigtables.exe -gettext_strings_test -/gnulib -grub-bin2h -/grub-bios-setup -/grub-bios-setup.exe -grub_cmd_date -grub_cmd_echo -grub_cmd_regexp -grub_cmd_set_date -grub_cmd_sleep -/grub-editenv -/grub-editenv.exe -grub-emu -grub-emu-lite -grub-emu.exe -grub-emu-lite.exe -grub_emu_init.c -grub_emu_init.h -/grub-file -/grub-file.exe -grub-fstest -grub-fstest.exe -grub_fstest_init.c -grub_fstest_init.h -grub_func_test -grub-install -grub-install.exe -grub-kbdcomp -/grub-macbless -/grub-macbless.exe -grub-macho2img -/grub-menulst2cfg -/grub-menulst2cfg.exe -/grub-mk* -grub-mount -/grub-ofpathname -/grub-ofpathname.exe -grub-core/build-grub-pe2elf.exe -/grub-probe -/grub-probe.exe -grub_probe_init.c -grub_probe_init.h -/grub-reboot -grub_script_blanklines -grub_script_blockarg -grub_script_break -grub-script-check -grub-script-check.exe -grub_script_check_init.c -grub_script_check_init.h -grub_script_comments -grub_script_continue -grub_script_dollar -grub_script_echo1 -grub_script_echo_keywords -grub_script_escape_comma -grub_script_eval -grub_script_expansion -grub_script_final_semicolon -grub_script_for1 -grub_script_functions -grub_script_gettext -grub_script_if -grub_script_leading_whitespace -grub_script_no_commands -grub_script_not -grub_script_return -grub_script_setparams -grub_script_shift -grub_script_strcmp -grub_script_test -grub_script_vars1 -grub_script_while1 -grub_script.tab.c -grub_script.tab.h -grub_script.yy.c -grub_script.yy.h -grub-set-default -grub_setup_init.c -grub_setup_init.h -grub-shell -grub-shell-tester -grub-sparc64-setup -grub-sparc64-setup.exe -/grub-syslinux2cfg -/grub-syslinux2cfg.exe -gzcompress_test -hddboot_test -help_test -*.img *.image *.image.exe -include/grub/cpu -include/grub/machine -INSTALL.grub -install-sh -lib/libgcrypt-grub -libgrub_a_init.c +*.img *.log *.lst -lzocompress_test *.marker -Makefile -/m4 *.mod -mod-*.c -missing -netboot_test *.o -*.a -ohci_test -partmap_test -pata_test *.pf2 *.pp -po/*.mo -po/grub.pot -po/Makefile.in.in -po/Makevars -po/Makevars.template -po/POTFILES -po/Rules-quot -po/stamp-po -printf_test -priority_queue_unit_test -pseries_test -stamp-h -stamp-h1 -stamp-h.in -symlist.c -symlist.h -trigtables.c *.trs -uhci_test -update-grub_lib -unidata.c -xzcompress_test -Makefile.in +*~ +.deps-core/ +.deps-util/ +.deps/ +.dirstamp +DISTLIST GPATH GRTAGS GSYMS GTAGS -compile -depcomp +Makefile +Makefile.in +ascii.bitmaps +genkernsyms.sh +gensymlist.sh +grub-bin2h +grub-emu +grub-emu-lite +grub-emu-lite.exe +grub-emu.exe +grub-macho2img +grub_emu_init.c +grub_emu_init.h +grub_probe_init.c +grub_probe_init.h +grub_script.tab.c +grub_script.tab.h +grub_script.yy.c +grub_script.yy.h +grub_script_check_init.c +grub_script_check_init.h +grub_setup_init.c +grub_setup_init.h mdate-sh -texinfo.tex -grub-core/lib/libgcrypt-grub -.deps -.deps-util -.deps-core -.dirstamp -Makefile.util.am -contrib -grub-core/bootinfo.txt -grub-core/Makefile.core.am -grub-core/Makefile.gcry.def -grub-core/contrib -grub-core/gdb_grub -grub-core/genmod.sh -grub-core/gensyminfo.sh -grub-core/gmodule.pl -grub-core/grub.chrp -grub-core/modinfo.sh -grub-core/*.module -grub-core/*.module.exe -grub-core/*.pp -grub-core/kernel.img.bin -util/bash-completion.d/grub -grub-core/lib/gnulib -grub-core/rs_decoder.h +mod-*.c +update-grub_lib widthspec.bin -widthspec.h -docs/stamp-1 -docs/version-dev.texi -Makefile.utilgcry.def -po/*.po -po/*.gmo -po/LINGUAS -po/remove-potcdate.sed -include/grub/gcrypt/gcrypt.h -include/grub/gcrypt/g10lib.h -po/POTFILES.in -po/POTFILES-shell.in -/grub-glue-efi -/grub-render-label -/grub-glue-efi.exe -/grub-render-label.exe + +# +# Ignore patterns relative to this .gitignore file's directory. +# +/00_header +/10_* +/20_linux_xen +/30_os-prober +/30_uefi-firmware +/40_custom +/41_custom +/ABOUT-NLS +/ChangeLog +/INSTALL.grub +/Makefile.util.am +/Makefile.utilgcry.def +/aclocal.m4 +/ahci_test +/ascii.h +/autom4te.cache/ +/btrfs_test +/build-aux/ +/build-grub-gen-asciih +/build-grub-gen-widthspec +/build-grub-mkfont +/cdboot_test +/cmp_test +/compile +/config-util.h +/config-util.h.in +/config.cache +/config.guess +/config.h +/config.log +/config.status +/config.sub +/configure +/contrib +/core_compress_test +/cpio_test +/date_test +/depcomp +/docs/*.info +/docs/*.info-[0-9]* +/docs/stamp-1 +/docs/stamp-vti +/docs/version-dev.texi +/docs/version.texi +/ehci_test +/example_grub_script_test +/example_scripted_test +/example_unit_test +/exfat_test +/ext234_test +/f2fs_test +/fat_test +/fddboot_test +/file_filter_test /garbage-gen /garbage-gen.exe +/gettext_strings_test +/gnulib/ +/grub-2.[0-9]*/ +/grub-2.[0-9]*.tar.gz +/grub-bios-setup +/grub-bios-setup.exe +/grub-core/*.module +/grub-core/*.module.exe +/grub-core/*.pp +/grub-core/Makefile.core.am +/grub-core/Makefile.gcry.def +/grub-core/bootinfo.txt +/grub-core/build-grub-module-verifier +/grub-core/build-grub-pe2elf.exe +/grub-core/contrib +/grub-core/gdb_grub +/grub-core/genmod.sh +/grub-core/gensyminfo.sh +/grub-core/gentrigtables +/grub-core/gentrigtables.exe +/grub-core/gmodule.pl +/grub-core/grub.chrp +/grub-core/kernel.img.bin +/grub-core/lib/gnulib +/grub-core/lib/libgcrypt-grub +/grub-core/modinfo.sh +/grub-core/rs_decoder.h +/grub-core/symlist.c +/grub-core/symlist.h +/grub-core/trigtables.c +/grub-core/unidata.c +/grub-editenv +/grub-editenv.exe +/grub-file +/grub-file.exe /grub-fs-tester -grub-core/build-grub-module-verifier +/grub-fstest +/grub-fstest.exe +/grub-glue-efi +/grub-glue-efi.exe +/grub-install +/grub-install.exe +/grub-kbdcomp +/grub-macbless +/grub-macbless.exe +/grub-menulst2cfg +/grub-menulst2cfg.exe +/grub-mk* +/grub-mount +/grub-ofpathname +/grub-ofpathname.exe +/grub-probe +/grub-probe.exe +/grub-reboot +/grub-render-label +/grub-render-label.exe +/grub-script-check +/grub-script-check.exe +/grub-set-default +/grub-shell +/grub-shell-tester +/grub-sparc64-setup +/grub-sparc64-setup.exe +/grub-syslinux2cfg +/grub-syslinux2cfg.exe +/grub_cmd_date +/grub_cmd_echo +/grub_cmd_regexp +/grub_cmd_set_date +/grub_cmd_sleep +/grub_cmd_test +/grub_cmd_tr +/grub_fstest_init.c +/grub_fstest_init.h +/grub_func_test +/grub_script_blanklines +/grub_script_blockarg +/grub_script_break +/grub_script_comments +/grub_script_continue +/grub_script_dollar +/grub_script_echo1 +/grub_script_echo_keywords +/grub_script_escape_comma +/grub_script_eval +/grub_script_expansion +/grub_script_final_semicolon +/grub_script_for1 +/grub_script_functions +/grub_script_gettext +/grub_script_if +/grub_script_leading_whitespace +/grub_script_no_commands +/grub_script_not +/grub_script_return +/grub_script_setparams +/grub_script_shift +/grub_script_strcmp +/grub_script_test +/grub_script_vars1 +/grub_script_while1 +/gzcompress_test +/hddboot_test +/help_test +/hfs_test +/hfsplus_test +/include/grub/cpu +/include/grub/gcrypt/g10lib.h +/include/grub/gcrypt/gcrypt.h +/include/grub/machine +/install-sh +/iso9660_test +/jfs_test +/lib/libgcrypt-grub +/libgrub_a_init.c +/lzocompress_test +/m4/ +/minixfs_test +/missing +/netboot_test +/nilfs2_test +/ntfs_test +/ohci_test +/partmap_test +/pata_test +/po/*.gmo +/po/*.mo +/po/*.po +/po/LINGUAS +/po/Makefile.in.in +/po/Makevars +/po/Makevars.template +/po/POTFILES +/po/POTFILES-shell.in +/po/POTFILES.in +/po/Rules-quot +/po/grub.pot +/po/remove-potcdate.sed +/po/stamp-po +/printf_test +/priority_queue_unit_test +/pseries_test +/reiserfs_test +/romfs_test +/squashfs_test +/stamp-h +/stamp-h.in +/stamp-h1 +/syslinux_test +/tar_test +/test_sha512sum +/test_unset +/tests/syslinux/ubuntu10.04_grub.cfg +/texinfo.tex +/udf_test +/uhci_test +/util/bash-completion.d/grub +/widthspec.h +/xfs_test +/xzcompress_test +/zfs_test diff --git a/grub.macros b/grub.macros index 0498dae..577e943 100644 --- a/grub.macros +++ b/grub.macros @@ -333,8 +333,6 @@ git commit -a -q -m "%{tarversion} baseline." \ #git commit -a -q -m "%{tarversion} master." \ git am --whitespace=nowarn %%{patches} grub-%{grubefiarch}-%{tarversion}/.gitignore cp %{SOURCE4} grub-%{grubefiarch}-%{tarversion}/unifont.pcf.gz +sed -e "s,@@VERSION@@,%{version},g" -e "s,@@VERSION_RELEASE@@,%{version}-%{release},g" \ + %{SOURCE12} > grub-%{grubefiarch}-%{tarversion}/sbat.csv git add grub-%{grubefiarch}-%{tarversion} %endif %if 0%{with_alt_efi_arch} @@ -551,6 +554,16 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Fri Mar 12 2021 Javier Martinez Canillas - 2.06~rc1-1 +- Update to 2.06~rc1 to fix a bunch of CVEs + Resolves: CVE-2020-14372 + Resolves: CVE-2020-25632 + Resolves: CVE-2020-25647 + Resolves: CVE-2020-27749 + Resolves: CVE-2020-27779 + Resolves: CVE-2021-20225 + Resolves: CVE-2021-20233 + * Thu Mar 11 2021 Javier Martinez Canillas - 2.04-39 - Fix config file generation failing due invalid petitboot version value Resolves: rhbz#1921479 diff --git a/sbat.csv.in b/sbat.csv.in new file mode 100755 index 0000000..ea697f5 --- /dev/null +++ b/sbat.csv.in @@ -0,0 +1,3 @@ +sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md +grub,1,Free Software Foundation,grub,@@VERSION@@,https//www.gnu.org/software/grub/ +grub.fedora,1,The Fedora Project,grub2,@@VERSION_RELEASE@@,https://src.fedoraproject.org/rpms/grub2 diff --git a/sources b/sources index 9bd1834..5251e5d 100644 --- a/sources +++ b/sources @@ -1,4 +1,4 @@ SHA512 (unifont-5.1.20080820.pcf.gz) = 8939e2bc82ca97b60e6678f3ff079a2be7ba9b702f2e8ee289e853af5823695f7baafbf14b674fc5e41071f2a6de4f2dadd56bf8b4653849dd756d59622f1649 SHA512 (theme.tar.bz2) = 0f6f914d5f801509403094b28b8cfe5169cb56ae9bdd808ae21a6780a8236b434161a068351508dd78729c25ee2fed066c124c1eef9e15102750b409b4576a5c -SHA512 (grub-2.04.tar.xz) = 9c15c42d0cf5d61446b752194e3b628bb04be0fe6ea0240ab62b3d753784712744846e1f7c3651d8e0968d22012e6d713c38c44936d4004ded3ca4d4007babbb -SHA512 (gnulib-fixes.tar.gz) = c45de2126598485bcf2fee81a66e64afa0e253aa04fc796c9201dd50229a93cc086d635a21d4644cb454ad6f71fa342494573aa86478fca19059cf71836b0619 +SHA512 (grub-2.06~rc1.tar.xz) = 093890b0af71b0d346afb415dec106681fd9e3f2f5bda14093c060b861d55ee1b50c8fb24afd072d24968ebebedde290f8220b0374cbd2b2e4508dfb00924122 +SHA512 (gnulib-fixes.tar.gz) = 7aa933812de10f54196c7ed02079d7edeb92672a528baf83201ca4c62aa3e6b119f61c45469d2c4623c4efc5d4a08d20b029403f1f2c6e35fb7cb15789ff54b2