Ensure that we have a description string. When unspecified, default to "".

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2018-01-05 07:09:09 +00:00
parent 53584cf69c
commit da15338df8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=327572

View file

@ -591,12 +591,7 @@ create_loadopt(uint8_t *buf, size_t bufmax, uint32_t attributes, efidp dp, size_
/*
* Compute the length to make sure the passed in buffer is long enough.
*/
if (description)
utf8_to_ucs2(description, &bbuf, &desc_len);
else {
desc_len = 0;
bbuf = NULL;
}
utf8_to_ucs2(description, &bbuf, &desc_len);
len = sizeof(uint32_t) + sizeof(uint16_t) + desc_len + dp_size + optional_data_size;
if (len > bufmax) {
free(bbuf);
@ -636,6 +631,8 @@ make_boot_var(const char *label, const char *loader, const char *kernel, const c
char *bootvar = NULL;
int ret;
assert(label != NULL);
bootvar = make_next_boot_var_name();
if (bootvar == NULL)
err(1, "bootvar creation");
@ -755,7 +752,7 @@ print_loadopt_str(uint8_t *data, size_t datalen)
}
static char *
get_descr(uint8_t* data)
get_descr(uint8_t *data)
{
uint8_t *pos = data;
efi_char *desc;
@ -861,8 +858,8 @@ main(int argc, char *argv[])
/*
* side effect, adds to boot order, but not yet active.
*/
make_boot_var(opts.label, opts.loader, opts.kernel, opts.env,
opts.dry_run);
make_boot_var(opts.label ? opts.label : "",
opts.loader, opts.kernel, opts.env, opts.dry_run);
else if (opts.set_active || opts.set_inactive )
handle_activity(opts.bootnum, opts.set_active);
else if (opts.order != NULL)