rhboot / efibootmgr

efibootmgr development tree
GNU General Public License v2.0
519 stars 99 forks source link

Cannot create boot entry with extra arguments #36

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hello,

tryed

efibootmgr -d /dev/sda -p 1 -c -L "Arch Linux" -l /vmlinuz-linux -u "root=/dev/sda2 rw initrd=/initramfs-linux.img"

fails with

efibootmgr: Could not set variable: Invalid argument efibootmgr: Could not prepare boot variable: Invalid argument

. Same arguments working with 0.11.0.

regards

jared-dominguez commented 9 years ago

It would probably help to state what versions of efibootmgr and libefivar you're using.

ghost commented 9 years ago

Hi,

sure, i'm sorry: efibootmgr 0.12 and efivar 0.20

regards

benjarobin commented 9 years ago

The bug is around the first call to efi_loadopt_create which doesn't allow dp = NULL

Edit: The "bug" is not in efibootmgr but inside the efivar project. The check (!dp) should be after the check (size == 0)

This condition should be spitted

if (!dp && dp_size == 0) {
     errno = EINVAL;
     return -1;
}

Before if (size == 0) return sz;

if (dp_size == 0) {
     errno = EINVAL;
     return -1;
}

And after if (size == 0) return sz;

if (!dp) {
     errno = EINVAL;
     return -1;
}

Same thing with optional_data...

benjarobin commented 9 years ago

The bug was already referenced here : https://github.com/rhinstaller/efivar/issues/22

vathpela commented 9 years ago

This is fixed in efivar-0.21 with https://github.com/rhinstaller/efivar/commit/d07807c80cffa32460c10ddb0f76ac49d9c00387 . Thanks for the report!