X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fefivars.c;h=8d004bad33525832237f942cadd9c435d2623691;hb=b32ff512191bf873266ee8067f6f6c8a30c96a5e;hp=4fb77428f22a2b94d79f1ca349a225b40d898582;hpb=bc6f2e7c62bcd08177f879423188c54289694619;p=elogind.git diff --git a/src/shared/efivars.c b/src/shared/efivars.c index 4fb77428f..8d004bad3 100644 --- a/src/shared/efivars.c +++ b/src/shared/efivars.c @@ -111,7 +111,7 @@ int efi_get_variable( n = read(fd, r, (size_t) st.st_size - 4); if (n < 0) { free(r); - return (int) -n; + return -errno; } if (n != (ssize_t) st.st_size - 4) { free(r); @@ -231,10 +231,12 @@ int efi_get_boot_option( if (title_size > l - offsetof(struct boot_option, title)) return -EINVAL; - s = utf16_to_utf8(header->title, title_size); - if (!s) { - err = -ENOMEM; - goto err; + if (title) { + s = utf16_to_utf8(header->title, title_size); + if (!s) { + err = -ENOMEM; + goto err; + } } if (header->path_len > 0) { @@ -270,12 +272,13 @@ int efi_get_boot_option( if (dpath->drive.signature_type != 0x02) continue; - efi_guid_to_id128(dpath->drive.signature, &p_uuid); + if (part_uuid) + efi_guid_to_id128(dpath->drive.signature, &p_uuid); continue; } /* Sub-Type 4 – File Path */ - if (dpath->sub_type == 0x04) { + if (dpath->sub_type == 0x04 && !p && path) { p = utf16_to_utf8(dpath->path, dpath->length-4); continue; }