OSDN Git Service

android-x86/external-efibootmgr.git
8 years ago.spec: fix requirements for newer efivar and man page path.
Peter Jones [Wed, 10 Aug 2016 21:57:56 +0000 (17:57 -0400)]
.spec: fix requirements for newer efivar and man page path.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: use efivar's error facility.
Peter Jones [Wed, 10 Aug 2016 21:54:49 +0000 (17:54 -0400)]
efibootmgr: use efivar's error facility.

8 years agoStop preceeding our version number with a "0.".
Peter Jones [Tue, 19 Jul 2016 15:54:17 +0000 (11:54 -0400)]
Stop preceeding our version number with a "0.".

It's useless and it just makes people whine about it not being >1.0.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoREADME: update github link
Mike Gilbert [Mon, 30 May 2016 16:06:52 +0000 (12:06 -0400)]
README: update github link

8 years agoREADME: fix netboot command line since we have acpi bits now.
Peter Jones [Tue, 24 May 2016 15:56:33 +0000 (11:56 -0400)]
README: fix netboot command line since we have acpi bits now.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: fix usage of efi_loadopt_path() /again/.
Peter Jones [Tue, 24 May 2016 15:33:20 +0000 (11:33 -0400)]
efibootmgr: fix usage of efi_loadopt_path() /again/.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: fix up a lot of error result codes.
Peter Jones [Mon, 2 May 2016 17:12:58 +0000 (13:12 -0400)]
efibootmgr: fix up a lot of error result codes.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoHandle "-@ -" correctly again.
Peter Jones [Mon, 2 May 2016 15:38:07 +0000 (11:38 -0400)]
Handle "-@ -" correctly again.

This should fix issue #39.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoAdd lacking description of man for -m and -M option
Taku Izumi [Fri, 11 Mar 2016 02:45:27 +0000 (11:45 +0900)]
Add lacking description of man for -m and -M option

Currently there's no description of efibootmgr man page
for -m and -M option.

This patch adds the lacking description for -m and -M
option.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
8 years agoAdd lacking description of man for -m and -M option
Taku Izumi [Thu, 10 Mar 2016 01:45:57 +0000 (10:45 +0900)]
Add lacking description of man for -m and -M option

Currently there's no description of efibootmgr man page
for -m and -M option.

This patch adds the lacking description for -m and -M
option.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
8 years agoExplicitly pass a mode to efi_set_variable() in all cases.
Peter Jones [Thu, 3 Mar 2016 14:50:03 +0000 (09:50 -0500)]
Explicitly pass a mode to efi_set_variable() in all cases.

We'll have to do this for efivar-0.24 .

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr.spec: allow building on arm
Peter Jones [Thu, 25 Feb 2016 19:29:37 +0000 (14:29 -0500)]
efibootmgr.spec: allow building on arm

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr.spec: require popt-devel
Peter Jones [Thu, 25 Feb 2016 19:29:16 +0000 (14:29 -0500)]
efibootmgr.spec: require popt-devel

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: fix some types the compiler doesn't like.
Peter Jones [Thu, 25 Feb 2016 19:16:38 +0000 (14:16 -0500)]
efibootmgr: fix some types the compiler doesn't like.

Basically uint8_t * vs char *.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootdump: add efibootdump
Peter Jones [Thu, 25 Feb 2016 15:54:23 +0000 (10:54 -0500)]
efibootdump: add efibootdump

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootnext: add make targets (but not default)
Peter Jones [Thu, 25 Feb 2016 15:53:22 +0000 (10:53 -0500)]
efibootnext: add make targets (but not default)

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefoconman: remove from default make targets for now
Peter Jones [Thu, 25 Feb 2016 15:52:40 +0000 (10:52 -0500)]
efoconman: remove from default make targets for now

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: update for efivar 0.24
Peter Jones [Thu, 25 Feb 2016 15:43:40 +0000 (10:43 -0500)]
efibootmgr: update for efivar 0.24

As of 0.24 efi_loadopt_pathlen() and efi_loadopt_path() require a limit
argument to avoid overruns of the input data.

This patch adds reasonable limits to those calls.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoAdd -Wextra, because it finds a lot of bugs in GCC6
Peter Jones [Thu, 18 Feb 2016 16:10:08 +0000 (11:10 -0500)]
Add -Wextra, because it finds a lot of bugs in GCC6

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoeficonman: intialize poptOptions with named initializers.
Peter Jones [Thu, 18 Feb 2016 16:05:21 +0000 (11:05 -0500)]
eficonman: intialize poptOptions with named initializers.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoAdd efibootnext beginnings
Peter Jones [Thu, 19 Nov 2015 19:48:19 +0000 (14:48 -0500)]
Add efibootnext beginnings

efibootnext will (eventually) attempt to find any suitable boot device
and set it as BootNext.  To be used when other variable writes have
failed, in case it will use less space.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoAdd eficonman beginnings
Peter Jones [Thu, 12 Nov 2015 15:56:22 +0000 (10:56 -0500)]
Add eficonman beginnings

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoFix insusufficient validation check of -M option
Taku Izumi [Tue, 26 Jan 2016 05:32:50 +0000 (14:32 +0900)]
Fix insusufficient validation check of -M option

The acceptable range of -M (--mirror-above-4G) option should
be from 0 to 50. So the negative value should be rejected.
Otherwise unintended value can be specified.

e.g.

 > efibootmgr -M -3
...
MirroredPercentageAbove4G: 25.00
MirrorMemoryBelow4GB: true
RequestMirroredPercentageAbove4G: 652.36
RequestMirrorMemoryBelow4GB: true

 652.36 is invalid value for MirroredPercentageAbove4G and should
 not be specified.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
8 years agoAdd LOCALEDIR make goo
Peter Jones [Thu, 12 Nov 2015 15:57:15 +0000 (10:57 -0500)]
Add LOCALEDIR make goo

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoSimplify directory structure.
Peter Jones [Tue, 4 Aug 2015 14:36:31 +0000 (10:36 -0400)]
Simplify directory structure.

We're making a lot less stuff than we did before libefivar.so existed,
and there's not a lot of reason for it.  Collapse the directory
structure entirely, and move to more modern makefiles.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoSet pkg-config binary as variable
Timo Gurr [Tue, 30 Jun 2015 09:33:14 +0000 (11:33 +0200)]
Set pkg-config binary as variable

Allow the location of the pkg-config binary to be set using the
parameter PKG_CONFIG. Needed to support cross compilation toolchains.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake it a little clearer what's going on when efi_del_variable() fails.
Peter Jones [Thu, 25 Jun 2015 13:56:37 +0000 (09:56 -0400)]
Make it a little clearer what's going on when efi_del_variable() fails.

Right now if efi_del_variable() fails we try a couple of things for
compatibility reasons and we have too many different error messages.
Hopefully this makes it clearer.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoINSTALL: add note about missing efivar.h error
Jody Bruchon [Thu, 21 May 2015 12:16:08 +0000 (08:16 -0400)]
INSTALL: add note about missing efivar.h error

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoSet guid when reading boot entries in read_vars.
Alexis Murzeau [Sat, 18 Apr 2015 21:03:23 +0000 (23:03 +0200)]
Set guid when reading boot entries in read_vars.

set_active_state use boot->guid, so set it to EFI_GLOBAL_GUID.

9 years agoDelete BootOrder only when necessary.
Shih-Yuan Lee (FourDollars) [Mon, 1 Jun 2015 10:36:40 +0000 (18:36 +0800)]
Delete BootOrder only when necessary.

Signed-off-by: Shih-Yuan Lee (FourDollars) <sylee@ubuntu.com>
9 years agoAdd -m and -M options to support address range mirror
Luck, Tony [Tue, 9 Jun 2015 17:14:58 +0000 (10:14 -0700)]
Add -m and -M options to support address range mirror

BIOS and OS pass messages for address range mirror using a pair of
UEFI variables:

   MirrorCurrent: Written by BIOS to tell the OS that the platform supports
address range mirror and to say whether mirroring was set up using
the desired parameters
   MirrorRequest: Written by OS to tell BIOS new paramters to use on next boot

This is documented in the RAS validation guide for memory address range
mirroring for the Xeon E7-v3 family:

  https://software.intel.com/sites/default/files/managed/43/6a/Memory%20Address%20Range%20Mirroring%20Validation%20Guide.pdf

Signed-off-by: Tony Luck <tony.luck@intel.com>
9 years agoUpdate version to 0.12
Peter Jones [Thu, 28 May 2015 13:50:37 +0000 (09:50 -0400)]
Update version to 0.12

- use -lefivar and -lefiboot to make device paths and load options.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoUpdate build deps in the spec to match what libraries we actually use.
Peter Jones [Thu, 28 May 2015 14:16:47 +0000 (10:16 -0400)]
Update build deps in the spec to match what libraries we actually use.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake the release procedure a bit more streamlined.
Peter Jones [Thu, 28 May 2015 13:50:20 +0000 (09:50 -0400)]
Make the release procedure a bit more streamlined.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoAdd some language about efivar in INSTALL
Peter Jones [Wed, 27 May 2015 18:22:44 +0000 (14:22 -0400)]
Add some language about efivar in INSTALL

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of pci-utils and zlib deps; we don't need them any more.
Peter Jones [Wed, 27 May 2015 18:06:26 +0000 (14:06 -0400)]
Get rid of pci-utils and zlib deps; we don't need them any more.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake loadopt function names use efivar-0.19 names.
Peter Jones [Wed, 27 May 2015 18:06:06 +0000 (14:06 -0400)]
Make loadopt function names use efivar-0.19 names.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet us back to where we were before with network entries.
Peter Jones [Thu, 30 Apr 2015 17:59:00 +0000 (13:59 -0400)]
Get us back to where we were before with network entries.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoWe don't need the ucs2/utf8 code either.
Peter Jones [Thu, 30 Apr 2015 15:31:39 +0000 (11:31 -0400)]
We don't need the ucs2/utf8 code either.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of efichar.h; it's no longer used.
Peter Jones [Thu, 30 Apr 2015 15:23:18 +0000 (11:23 -0400)]
Get rid of efichar.h; it's no longer used.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix the github url once more.
Peter Jones [Thu, 30 Apr 2015 15:14:42 +0000 (11:14 -0400)]
Fix the github url once more.

This currently lives under the rhinstaller github account.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of manually specified ACPI arguments; we don't need them.
Peter Jones [Thu, 30 Apr 2015 15:08:21 +0000 (11:08 -0400)]
Get rid of manually specified ACPI arguments; we don't need them.

Since we have pretty good detection of acpi hid/uid now, we don't
actually need them to be manually specified anywhere.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake -e 1 and -e 3 work again after the libefiboot shuffle.
Peter Jones [Wed, 29 Apr 2015 19:13:10 +0000 (15:13 -0400)]
Make -e 1 and -e 3 work again after the libefiboot shuffle.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake file boot option creation use libefiboot to create the device path.
Peter Jones [Tue, 7 Apr 2015 20:14:43 +0000 (16:14 -0400)]
Make file boot option creation use libefiboot to create the device path.

(right now network options are horribly broken, but they never really
worked anyway, so... yeah, I'll fix them in a subsequent commit.)

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoAdd "efibootmgr -C"; create only without appending to BootOrder
Peter Jones [Tue, 31 Mar 2015 14:56:08 +0000 (10:56 -0400)]
Add "efibootmgr -C"; create only without appending to BootOrder

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of a lot of DP stuff that efivar does now.
Peter Jones [Tue, 31 Mar 2015 14:55:35 +0000 (10:55 -0400)]
Get rid of a lot of DP stuff that efivar does now.

9 years agoGet run of unparse_path() and unparse_raw()
Peter Jones [Mon, 2 Mar 2015 20:23:47 +0000 (15:23 -0500)]
Get run of unparse_path() and unparse_raw()

We don't use these any more.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake show_boot_vars use efivars DP formatting code.
Peter Jones [Fri, 27 Feb 2015 18:31:11 +0000 (13:31 -0500)]
Make show_boot_vars use efivars DP formatting code.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't depend on vendor-defined calloc(n, 0) behavior.
Peter Jones [Mon, 12 Jan 2015 19:15:24 +0000 (14:15 -0500)]
Don't depend on vendor-defined calloc(n, 0) behavior.

If we don't have any boot variables, we know that 0 is free, so just
return that.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoTest a couple of pointers for NULL-ness.
Peter Jones [Mon, 12 Jan 2015 19:09:23 +0000 (14:09 -0500)]
Test a couple of pointers for NULL-ness.

In both of these cases buf is NULL if and only if the size is also 0,
and thus we'll fail the test anyway, but coverify isn't noticing that.
And I'm tired of talking to a piece of software about its deficiencies.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFree some stuff in error pathways.
Peter Jones [Mon, 12 Jan 2015 19:03:06 +0000 (14:03 -0500)]
Free some stuff in error pathways.

This is just to make covscan gripe less.  These variables are legitimate
leaks, though the program is just going to exit afterward anyway.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't malloc(0).
Peter Jones [Mon, 12 Jan 2015 19:05:17 +0000 (14:05 -0500)]
Don't malloc(0).

This is covscan noticing that we're starting at 0 hunks instead of 1
hunk, and that means the first allocation is of 0 bytes, which is inane.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix buffer overflow when remove_from_boot_order removes nothing
Lenny Szubowicz [Tue, 6 Jan 2015 16:17:01 +0000 (11:17 -0500)]
Fix buffer overflow when remove_from_boot_order removes nothing

Deleting a boot entry via "-b xxxx -B" also attempts to remove
that entry from boot order via a call to remove_from_boot_order.
Although unusual, it's possible that the entry being deleted is
not in boot order. Correct the handling of this case in
remove_from_boot_order, which malloc's space for the new boot
order list wrongly assuming that at least one entry will be
removed. However, if no entry is removed, then 2 bytes are
overwritten beyond the malloc'ed space. This can result in heap
corruption and possible termination via a SIGABRT if the
corruption is detected by the heap allocation routines.

While there, simplify the routine to do the removal of boot
entries in place in the original data buffer, skip the
unnecessary BootOrder variable update if nothing got removed,
and free the malloc'ed boot_order struct on the way out.

Resolves: RH BZ 1168019

Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
9 years agoSkip unreadable variables, but don't exit when we do so.
Daniel Jared Dominguez [Thu, 18 Dec 2014 19:35:27 +0000 (14:35 -0500)]
Skip unreadable variables, but don't exit when we do so.

Old versions of efibootmgr and libefivar0 allowed the installation of
necessary EFI boot entries on the affected systems. It seems that an old
libefivar0 did not report read errors.

Then libefivar0 started to crash on unreadable variables (see Debian bug
764386). Since that bug has been fixed, efibootmgr doesn't crash
anymore, but the read errors are reported and efibootmgr always fails
with an input/output error.

Resolves: debian bug 768880

Signed-off-by: Jan Echternach <jan@goneko.de>
Signed-off-by: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake IPv6 network paths print correctly.
Peter Jones [Tue, 16 Dec 2014 15:01:10 +0000 (10:01 -0500)]
Make IPv6 network paths print correctly.

This should fix issue #13 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake IPv4() device paths print correctly.
Peter Jones [Tue, 16 Dec 2014 14:59:53 +0000 (09:59 -0500)]
Make IPv4() device paths print correctly.

We need to give the size to snprintf, not the offset.  The offset is
zero, so it'll only ever tell us the buffer size we need, even if we
have a reasonable buffer.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake the optional_data_len size signed.
Peter Jones [Tue, 16 Dec 2014 14:57:27 +0000 (09:57 -0500)]
Make the optional_data_len size signed.

Steve McIntyre's testing on i386 with efivars using the legacy path
(i.e. not efivarfs) also found a bug here - we're checking
optional_data_len for negative error values, but it's unsigned.  We're
not going to have 4GB of optional loader data, so just make it signed.

This should fix Issue #21 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix MAC() device path printing.
Peter Jones [Fri, 12 Dec 2014 21:01:00 +0000 (16:01 -0500)]
Fix MAC() device path printing.

67491a308 accidentally made it print MAC(MAC( .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoPrint a better message if BootOrder is unset.
Peter Jones [Thu, 11 Dec 2014 15:18:37 +0000 (10:18 -0500)]
Print a better message if BootOrder is unset.

This resolves issue #7 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't name something efi_variable_t; that namespace is used by efivar.
Peter Jones [Thu, 11 Dec 2014 14:37:00 +0000 (09:37 -0500)]
Don't name something efi_variable_t; that namespace is used by efivar.

Newer efivar has efi_variable_t as a type for its import/export api
(which efibootmgr can use at some point), so don't make a type with that
name internally here.

This fixes github issue #20

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoUpdate version to 0.10
Peter Jones [Tue, 21 Oct 2014 20:17:27 +0000 (16:17 -0400)]
Update version to 0.10

- Fix "-n" and friends not being assigned/checked right sometimes from
  0.10.0-1
- Generate more archives to avoid people using github's, because
  they're just bad.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDo even more absurd stuff to avoid github's terrible tarballs.
Peter Jones [Tue, 21 Oct 2014 20:14:54 +0000 (16:14 -0400)]
Do even more absurd stuff to avoid github's terrible tarballs.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoActually /set/ the values we're using to the results of parsing the number.
Peter Jones [Tue, 21 Oct 2014 20:02:13 +0000 (16:02 -0400)]
Actually /set/ the values we're using to the results of parsing the number.

This should fix https://github.com/vathpela/efibootmgr/issues/18

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't check if '-n' is a current boot entry so early.
Peter Jones [Tue, 21 Oct 2014 19:01:03 +0000 (15:01 -0400)]
Don't check if '-n' is a current boot entry so early.

We haven't made the list yet, so it'll always be wrong.

This should fix part of https://github.com/vathpela/efibootmgr/issues/18

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoAudit error checking in main().
Peter Jones [Mon, 20 Oct 2014 18:34:17 +0000 (14:34 -0400)]
Audit error checking in main().

Previously, one return value wound up not being checked at all,
resulting in https://github.com/vathpela/efibootmgr/issues/14 , and
several weren't checked as they should have been.

Sorry about that.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake the version 0.10.0
Peter Jones [Mon, 20 Oct 2014 16:21:02 +0000 (12:21 -0400)]
Make the version 0.10.0

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake all the other places we're parsing XXXX also do a better job.
Peter Jones [Mon, 20 Oct 2014 16:15:26 +0000 (12:15 -0400)]
Make all the other places we're parsing XXXX also do a better job.

This is related to https://github.com/vathpela/efibootmgr/issues/12 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake -o's behavior actually match the documented behavior.
Peter Jones [Mon, 20 Oct 2014 16:04:34 +0000 (12:04 -0400)]
Make -o's behavior actually match the documented behavior.

Also make it a bit better and reporting errors.

This should actually resolve
https://github.com/vathpela/efibootmgr/issues/12 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't error on unset BootOrder when we're trying to add to or rm from it.
Peter Jones [Wed, 15 Oct 2014 14:28:13 +0000 (10:28 -0400)]
Don't error on unset BootOrder when we're trying to add to or rm from it.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoProduce a slightly more succinct error when we get -EPERM on the disk.
Peter Jones [Wed, 15 Oct 2014 14:16:55 +0000 (10:16 -0400)]
Produce a slightly more succinct error when we get -EPERM on the disk.

Because one error message is enough.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't call EPERM "not found" when deleting variables.
Peter Jones [Wed, 15 Oct 2014 14:09:13 +0000 (10:09 -0400)]
Don't call EPERM "not found" when deleting variables.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agomanpage lists option '--test' which doesn't seem to exist
D. Jared Dominguez [Tue, 14 Oct 2014 21:24:02 +0000 (16:24 -0500)]
manpage lists option '--test' which doesn't seem to exist

I'm passing along this bug report from Debian:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759714

Here's a quick fix:

9 years agoAdd more error messages and better return codes.
Peter Jones [Wed, 15 Oct 2014 13:20:04 +0000 (09:20 -0400)]
Add more error messages and better return codes.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoOne more place we're not printing the error code.
Peter Jones [Tue, 14 Oct 2014 21:15:43 +0000 (17:15 -0400)]
One more place we're not printing the error code.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix a segfault in append_extra_args_ascii()
Peter Jones [Tue, 14 Oct 2014 21:09:37 +0000 (17:09 -0400)]
Fix a segfault in append_extra_args_ascii()

How that worked at all before was beyond me.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake a few more return paths print some modicum of error message.
Peter Jones [Tue, 14 Oct 2014 19:09:56 +0000 (15:09 -0400)]
Make a few more return paths print some modicum of error message.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't define our own ioctls unless we have to.
Peter Jones [Fri, 10 Oct 2014 21:09:51 +0000 (17:09 -0400)]
Don't define our own ioctls unless we have to.

The way it was, BLKGETSIZE64 wound up being 0x80041272 instead of the
0x80081272 it should be on -m32 builds.  4 isn't the size of 64 bits, so
that results in integer overflow into who knows what space on the stack,
and when we compare it to our gpt header, it's also just plain wrong.

This is all madness, of course, the kernel has exported all of this
stuff since the ancient past.  Use that instead.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoLinux kernel versions aren't always 3-tuples any more.
Peter Jones [Fri, 10 Oct 2014 20:42:08 +0000 (16:42 -0400)]
Linux kernel versions aren't always 3-tuples any more.

So we need to handle "3.10" as a version number correctly.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoClarify -o parameters.
Peter Jones [Wed, 8 Oct 2014 18:08:27 +0000 (14:08 -0400)]
Clarify -o parameters.

Clarify the values that can be given to -o, as it has led to some minor
confusion.

Resolves: https://github.com/vathpela/efibootmgr/issues/12

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoRelease 0.9.0
Peter Jones [Thu, 25 Sep 2014 18:00:18 +0000 (14:00 -0400)]
Release 0.9.0

I really should get rid of the third section of the version numbers.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't pass uninitialized data to efi_guid_to_str().
Peter Jones [Thu, 25 Sep 2014 16:46:43 +0000 (12:46 -0400)]
Don't pass uninitialized data to efi_guid_to_str().

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't leak our partition table structures.
Peter Jones [Wed, 10 Sep 2014 21:03:23 +0000 (17:03 -0400)]
Don't leak our partition table structures.

Covscan once more.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoCheck lseek() for errors.
Peter Jones [Wed, 10 Sep 2014 20:56:49 +0000 (16:56 -0400)]
Check lseek() for errors.

Covscan.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoCheck open()s return correctly.
Peter Jones [Wed, 10 Sep 2014 20:50:08 +0000 (16:50 -0400)]
Check open()s return correctly.

Covscan.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoCheck malloc() return.
Peter Jones [Wed, 10 Sep 2014 20:49:51 +0000 (16:49 -0400)]
Check malloc() return.

Covscan.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake a free non-conditional since the condition can't be ture.
Peter Jones [Wed, 10 Sep 2014 20:24:03 +0000 (16:24 -0400)]
Make a free non-conditional since the condition can't be ture.

Covscan again.  I wonder if it'll complain about this.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoHandle the case where there are no EFI variables.
Peter Jones [Wed, 10 Sep 2014 20:22:21 +0000 (16:22 -0400)]
Handle the case where there are no EFI variables.

So we're on an EFI machine with no variables, eh covscan?

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't reuse a pointer to static data and free conditionally.
Peter Jones [Wed, 10 Sep 2014 20:20:04 +0000 (16:20 -0400)]
Don't reuse a pointer to static data and free conditionally.

Instead, use a second pointer and free that, because poor covscan can't
figure out what's going on.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't free something that shouldn't ever be non-NULL.
Peter Jones [Wed, 10 Sep 2014 20:15:27 +0000 (16:15 -0400)]
Don't free something that shouldn't ever be non-NULL.

Instead, check and error if it's non-NULL.

(Covscan, which got this completely wrong.)

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoCovscan can't tell that we're not filling a buffer...
Peter Jones [Wed, 10 Sep 2014 20:07:02 +0000 (16:07 -0400)]
Covscan can't tell that we're not filling a buffer...

Because the pattern here is:

rc = func_call(buf, buflen)
if (rc < 0)
return error;
buflen = rc;
buf = calloc(1, buflen)
if (!buf)
return error;
rc = func_call(buf, buflen);

Covscan thinks the first func_call() might actually be doing something
to buf.  It isn't, but that's not obvious.  So make it NULL and 0
instead of buf and buflen on the first call.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of an invalid comparison.
Peter Jones [Wed, 10 Sep 2014 20:02:58 +0000 (16:02 -0400)]
Get rid of an invalid comparison.

Covscan.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoTry to avoid covscan freaking out about sscanf with %n.
Peter Jones [Wed, 10 Sep 2014 19:57:26 +0000 (15:57 -0400)]
Try to avoid covscan freaking out about sscanf with %n.

covscan says:

 5. efibootmgr-0.8.0/src/lib/disk.c:96:tainted_data_argument – Calling
 function "fgets(char * restrict, int, FILE * restrict)" taints argument
 "line".
 10. efibootmgr-0.8.0/src/lib/disk.c:103:vararg_transitive – Call to
 "sscanf(char const * restrict, char const * restrict, ...)" with
 tainted argument "line" taints "major".
 11. efibootmgr-0.8.0/src/lib/disk.c:103:vararg_transitive – Call to
 "sscanf(char const * restrict, char const * restrict, ...)" with
 tainted argument "line" taints "scanned".
 13. efibootmgr-0.8.0/src/lib/disk.c:103:tainted_data – Using tainted
 variable "scanned" as an index into an array "line".

I *think* that's really complaining that if sscanf fails before
processing %n, then "scanned" is indeterminate here.  So I've assigned
it to 0.

Either way, if any of that goes wrong, the code's going to completely
fail.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix an error path not checking the return right in make_linux_load_option
Peter Jones [Wed, 10 Sep 2014 19:47:57 +0000 (15:47 -0400)]
Fix an error path not checking the return right in make_linux_load_option

Covscan once again.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake sure data created for load options is freed.
Peter Jones [Wed, 10 Sep 2014 19:46:04 +0000 (15:46 -0400)]
Make sure data created for load options is freed.

Covscan... may not be right about this one.  But it's better to be sure.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix some minor memory leaks.
Peter Jones [Wed, 10 Sep 2014 19:40:29 +0000 (15:40 -0400)]
Fix some minor memory leaks.

Well, one and not really another.  Covscan is /almost/ a great tool.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix another leaked fd.
Peter Jones [Wed, 10 Sep 2014 19:34:12 +0000 (15:34 -0400)]
Fix another leaked fd.

Covscan some more.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't leak our socket's fd when determining network info.
Peter Jones [Wed, 10 Sep 2014 19:32:59 +0000 (15:32 -0400)]
Don't leak our socket's fd when determining network info.

Covscan again.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake the return path something coverity can actually understand.
Peter Jones [Wed, 10 Sep 2014 19:29:43 +0000 (15:29 -0400)]
Make the return path something coverity can actually understand.

It was *correct* before, but there's no reason to do it that weird way.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix a bad allocation size.
Peter Jones [Wed, 10 Sep 2014 19:27:02 +0000 (15:27 -0400)]
Fix a bad allocation size.

Covscan found this.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoRelease 0.8.0
Peter Jones [Tue, 9 Sep 2014 15:18:09 +0000 (11:18 -0400)]
Release 0.8.0

Signed-off-by: Peter Jones <pjones@redhat.com>