chiark / gitweb /
sd-event: fix typo
[elogind.git] / src / boot / bootctl.c
index 73450e283d4be98a0a7a1b358b9785f9104d6e63..ae467ca35c9cc569f3626c95835224a584b4b1a2 100644 (file)
@@ -41,7 +41,6 @@
 #include "efivars.h"
 #include "build.h"
 #include "util.h"
-#include "utf8.h"
 
 static int verify_esp(const char *p, uint32_t *part, uint64_t *pstart, uint64_t *psize, sd_id128_t *uuid) {
         struct statfs sfs;
@@ -178,7 +177,13 @@ static int verify_esp(const char *p, uint32_t *part, uint64_t *pstart, uint64_t
                 fprintf(stderr, "Failed to probe partition entry UUID %s: %s\n", p, strerror(-r));
                 goto fail;
         }
-        sd_id128_from_string(v, uuid);
+
+        r = sd_id128_from_string(v, uuid);
+        if (r < 0) {
+                fprintf(stderr, "Partition %s has invalid UUID: %s\n", p, v);
+                r = -EIO;
+                goto fail;
+        }
 
         errno = 0;
         r = blkid_probe_lookup_value(b, "PART_ENTRY_NUMBER", &v, NULL);
@@ -366,15 +371,15 @@ static int status_binaries(const char *esp_path, sd_id128_t partition) {
 }
 
 static int print_efi_option(uint16_t id, bool in_order) {
-        char *title = NULL;
-        char *path = NULL;
+        _cleanup_free_ char *title = NULL;
+        _cleanup_free_ char *path = NULL;
         sd_id128_t partition;
         bool active;
         int r = 0;
 
         r = efi_get_boot_option(id, &title, &partition, &path, &active);
         if (r < 0)
-                goto finish;
+                return r;
 
         /* print only configured entries with partition information */
         if (!path || sd_id128_equal(partition, SD_ID128_NULL))
@@ -389,10 +394,7 @@ static int print_efi_option(uint16_t id, bool in_order) {
         printf("         File: └─%s\n", path);
         printf("\n");
 
-finish:
-        free(title);
-        free(path);
-        return r;
+        return 0;
 }
 
 static int status_variables(void) {
@@ -897,7 +899,7 @@ finish:
 }
 
 static int remove_from_order(uint16_t slot) {
-        uint16_t *order = NULL;
+        _cleanup_free_ uint16_t *order = NULL;
         int n_order;
         int i;
         int err = 0;
@@ -918,7 +920,6 @@ static int remove_from_order(uint16_t slot) {
                 break;
         }
 
-        free(order);
         return err;
 }
 
@@ -1328,8 +1329,8 @@ static int bootctl_main(int argc, char*argv[]) {
                 efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderFirmwareType", &fw_type);
                 efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderFirmwareInfo", &fw_info);
                 efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderInfo", &loader);
-                efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderImageIdentifier", &loader_path);
-                efi_tilt_backslashes(loader_path);
+                if (efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderImageIdentifier", &loader_path) > 0)
+                        efi_tilt_backslashes(loader_path);
                 efi_loader_get_device_part_uuid(&loader_part_uuid);
 
                 printf("System:\n");