Commit Graph

35 Commits

Author SHA1 Message Date
Martin Whitaker 8451454889 grub-install: Fix inverted test for NLS enabled when copying locales
Commit 3d8439da8 (grub-install: Locale depends on nls) attempted to avoid
copying locale files to the target directory when NLS was disabled.
However the test is inverted, and it does the opposite.

Signed-off-by: Martin Whitaker <fsf@martin-whitaker.me.uk>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
2020-09-18 21:17:07 +02:00
Peter Jones f725fa7cb2 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 <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:47 +02:00
Colin Watson 62daa27056 util: Detect more I/O errors
Many of GRUB's utilities don't check anywhere near all the possible
write errors.  For example, if grub-install runs out of space when
copying a file, it won't notice.  There were missing checks for the
return values of write, fflush, fsync, and close (or the equivalents on
other OSes), all of which must be checked.

I tried to be consistent with the existing logging practices of the
various hostdisk implementations, but they weren't entirely consistent
to start with so I used my judgement.  The result at least looks
reasonable on GNU/Linux when I provoke a write error:

  Installing for x86_64-efi platform.
  grub-install: error: cannot copy `/usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed' to `/boot/efi/EFI/debian/grubx64.efi': No space left on device.

There are more missing checks in other utilities, but this should fix
the most critical ones.

Fixes Debian bug #922741.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Steve McIntyre <93sam@debian.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2019-03-05 10:23:47 +01:00
Alexander Graf f1957dc8a3 RISC-V: Add to build system
This patch adds support for RISC-V to the grub build system. With this
patch, I can successfully build grub on RISC-V as a UEFI application.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2019-02-25 14:02:05 +01:00
Juergen Gross 90b7b14fa5 xen_pvh: Support grub-install for xen_pvh
Add xen_pvh support to grub-install.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Hans van Kranenburg <hans@knorrie.org>
2018-12-12 12:03:28 +01:00
Olaf Hering 3d8439da8c grub-install: Locale depends on nls
With --disable-nls no locales exist.

Avoid runtime error by moving code that copies locales into its own
function. Return early in case nls was disabled. That way the compiler
will throw away unreachable code, no need to put preprocessor
conditionals everywhere to avoid warnings about unused code.

Fix memleak by freeing srcf and dstf.
Convert tabs to spaces in moved code.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:13:11 +02:00
Vladimir Serbinenko 3edabad8fe arm_coreboot: Support grub-mkstandalone. 2017-05-08 21:59:48 +02:00
Vladimir Serbinenko fcbb723d4b Add support for device-tree-based drivers. 2017-05-08 21:19:59 +02:00
Andrei Borzenkov 0e075ac385 util/setup: fix grub_util_path_list leak
Add helper grub_util_free_path_list and use it where appropriate.

Found by: Coverity scan.
CID: 73727
2016-01-09 13:55:18 +03:00
Andrei Borzenkov 5082ea6184 remove extra newlines in grub_util_* strings
grub_util_{info,warn,error} already add trailing newlines, so remove
them from format strings. Also trailing full stops are already added.
2015-05-13 09:47:17 +03:00
Vladimir Serbinenko 9916ed6f82 grub-install-common: Increase buf size to 8192 as modinfo.sh is bigger. 2015-05-07 17:09:58 +02:00
Andrei Borzenkov 5e27fb06f2 util/install: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Vladimir Serbinenko c3f5230597 grub-install-common: Fix sizeof usage.
Found by: Coverity scan.
2015-01-26 09:54:50 +01:00
Andrei Borzenkov 740c08ed2f Use ssize_t for grub_util_fd_read result
Fixes commit 0415dbe28f.
2014-11-28 21:43:07 +03:00
Andrei Borzenkov 0415dbe28f grub-install-common: avoid out of bound access when read failed
Check that modinfo.sh could be read successfully; abort on error. Avoids
potential out-of-bound array access.

CID: 73819
2014-11-28 20:45:27 +03:00
Vladimir Serbinenko 95cd131ea0 * util/grub-install.c: List available targets. 2014-01-24 18:09:25 +01:00
Vladimir Serbinenko e388db904c Install modinfo.sh to keep build information around. 2013-12-23 18:17:09 +01:00
Vladimir Serbinenko ae558c2ccf Enable -Wformat=2 if it's supported. 2013-12-21 15:28:28 +01:00
Vladimir Serbinenko 579ee114b1 Add missing static qualifiers. 2013-12-21 13:50:13 +01:00
Vladimir Serbinenko 636977b089 Mark strings for translation and add remaining ones to exclude list. 2013-12-18 06:50:24 +01:00
Vladimir Serbinenko f23bc65103 Transform -C option to grub-mkstandalone to --core-compress available
in all grub-install flavours.
2013-12-07 16:18:22 +01:00
Colin Watson 3a82f8bb48 Fix grub-shell to avoid breaking "make distcheck"
Copying the themes directory in grub-shell isn't
parallel-test-friendly and breaks on the second test when the source
directory is read-only (as in "make distcheck").  Instead, add a
hidden --themes-directory option to grub-mkrescue et al, and use it
in grub-shell.
2013-12-04 13:36:34 +00:00
Leif Lindholm b29b77fee2 New port arm64-efi 2013-11-30 16:50:31 +01:00
Vladimir Serbinenko 4f9541226c Introduce grub_util_file_sync and use it instead of fsync(fileno(f)).
Fixes build for windows.
2013-11-27 14:13:50 +01:00
Colin Watson 5c7206e45e Speed up test suite by avoiding fsync
Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls into
no-ops, and use it in programs that copy files but do not need to take
special care to sync writes (grub-mknetdir, grub-rescue,
grub-mkstandalone).

On my laptop, this reduces partmap_test's runtime from 1236 seconds to
204 seconds.
2013-11-27 10:10:22 +00:00
Colin Watson 07e3b04742 Add a --locale-directory option to grub-install and related tools.
* include/grub/util/install.h (GRUB_INSTALL_OPTIONS): Add
--locale-directory option.
(enum grub_install_options): Add
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
* util/grub-install-common.c (grub_install_help_filter): Handle
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
(grub_install_parse): Likewise.
(get_localedir): New function to check for a user-provided option
before trying grub_util_get_localedir.
(copy_locales): Use get_localedir rather than
grub_util_get_localedir.  Handle differing locale directory layouts.
(grub_install_copy_files): Likewise.
2013-11-25 18:04:50 +00:00
Vladimir Serbinenko d6c92cdc34 Merge branch 'master' into leiflindholm/arm64
Conflicts:
	include/grub/util/install.h
2013-11-25 13:02:27 +01:00
Vladimir Serbinenko 4a23e2fe29 Add *-xen to the list of grub-install-common platforms. 2013-11-22 14:21:16 +01:00
Colin Watson 4402db3ecc * util/grub-install-common.c (copy_locales): Consistently use
grub_util_get_localedir () rather than LOCALEDIR.
(grub_install_copy_files): Likewise.
2013-11-19 15:35:44 +00:00
Vladimir Serbinenko d3def58c52 Add missing arm64 declaration 2013-11-18 17:52:57 +01:00
Vladimir Serbinenko b40ce65180 * util/grub-install-common.c (grub_install_copy_files): Fix module
destination directory.
2013-11-18 15:59:55 +01:00
Vladimir Serbinenko a284320e1e Fix handling of install lists. 2013-11-18 11:38:00 +01:00
Vladimir Serbinenko 3a129dba59 * util/grub-install-common.c (grub_install_parse): Recognize
--compress=none like shell script did.
2013-11-17 02:01:21 +01:00
Vladimir Serbinenko d4d55b29e0 * util/grub-install-common.c (platforms): Fix the order of entries and
remove useless field val.
2013-11-17 00:54:40 +01:00
Vladimir Serbinenko cd46aa6cef Rewrite grub-install, grub-mkrescue, grub-mkstandalone and grub-mknetdir
the function of these files exceeds what can be sanely handled in shell
	in posix-comaptible way. Also writing it in C extends the functionality
	to non-UNIX-like OS and minimal environments.
2013-11-16 20:21:16 +01:00