From: Glenn Washburn Date: Thu, 9 Dec 2021 17:14:58 +0000 (-0600) Subject: cryptodisk: Improve handling of partition name in cryptomount password prompt X-Git-Tag: grub-2.12-rc1~507 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=de14c4b36db419761e17bddea90e4b62a0d8e501;p=thirdparty%2Fgrub.git cryptodisk: Improve handling of partition name in cryptomount password prompt 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 Reviewed-by: Daniel Kiper --- diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 7ca880402..497097394 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -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);