]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
cryptodisk: Improve handling of partition name in cryptomount password prompt
authorGlenn Washburn <development@efficientek.com>
Thu, 9 Dec 2021 17:14:58 +0000 (11:14 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 23 Dec 2021 01:35:57 +0000 (02:35 +0100)
Call grub_partition_get_name() unconditionally to initialize the part
variable. Then part will only be NULL when grub_partition_get_name() errors.
Note that when source->partition is NULL, then grub_partition_get_name()
returns an allocated empty string. So no comma or partition will be printed,
as desired.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/disk/cryptodisk.c

index 7ca880402d2f602f6373133f236fb7f543506928..497097394f78c398cf0dc68d8fc6d8c46eab85bd 100644 (file)
@@ -1021,11 +1021,10 @@ grub_cryptodisk_scan_device_real (const char *name,
       {
        /* Get the passphrase from the user, if no key data. */
        askpass = 1;
-       if (source->partition != NULL)
-         part = grub_partition_get_name (source->partition);
+       part = grub_partition_get_name (source->partition);
        grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), source->name,
                     source->partition != NULL ? "," : "",
-                    part != NULL ? part : "",
+                    part != NULL ? part : N_("UNKNOWN"),
                     dev->uuid);
        grub_free (part);