grub2/SOURCES/1000-Add-support-for-printableString-in-x509.patch

86 lines
2.8 KiB
Diff

From 14123e7711a5fec457c5b342c646c3a1f1544963 Mon Sep 17 00:00:00 2001
From: Andrew Lukoshko <alukoshko@almalinux.org>
Date: Sat, 29 Mar 2025 23:35:42 +0000
Subject: [PATCH] Add support for printableString in x509
Original patch by Daniel Axtens <dja@axtens.net>
Signed-off-by: Andrew Lukoshko <alukoshko@almalinux.org>
---
grub-core/commands/appendedsig/x509.c | 44 ++++++++++++++++++---------
1 file changed, 29 insertions(+), 15 deletions(-)
diff --git a/grub-core/commands/appendedsig/x509.c b/grub-core/commands/appendedsig/x509.c
index 42ec65c..e58dcab 100644
--- a/grub-core/commands/appendedsig/x509.c
+++ b/grub-core/commands/appendedsig/x509.c
@@ -310,22 +310,36 @@ decode_string (char *der, int der_size, char **string,
goto cleanup;
}
- if (grub_strncmp ("utf8String", choice, choice_size))
+ if (grub_strncmp ("utf8String", choice, choice_size) == 0)
{
- err =
- grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
- "Only UTF-8 DirectoryStrings are supported, got %s",
- choice);
- goto cleanup_choice;
+ result = asn1_read_value (strasn, "utf8String", NULL, &tmp_size);
+ if (result != ASN1_MEM_ERROR)
+ {
+ err =
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "Error reading size of UTF-8 string: %s",
+ asn1_strerror (result));
+ goto cleanup_choice;
+ }
}
-
- result = asn1_read_value (strasn, "utf8String", NULL, &tmp_size);
- if (result != ASN1_MEM_ERROR)
+ else if (grub_strncmp("printableString", choice, choice_size) == 0)
+ {
+ result = asn1_read_value (strasn, "printableString", NULL, &tmp_size);
+ if (result != ASN1_MEM_ERROR)
+ {
+ err =
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "Error reading size of UTF-8 string: %s",
+ asn1_strerror (result));
+ goto cleanup_choice;
+ }
+ }
+ else
{
err =
- grub_error (GRUB_ERR_BAD_FILE_TYPE,
- "Error reading size of UTF-8 string: %s",
- asn1_strerror (result));
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "Only UTF-8 and printable DirectoryStrings are supported, got %s",
+ choice);
goto cleanup_choice;
}
@@ -341,13 +355,13 @@ decode_string (char *der, int der_size, char **string,
goto cleanup_choice;
}
- result = asn1_read_value (strasn, "utf8String", *string, &tmp_size);
+ result = asn1_read_value (strasn, choice, *string, &tmp_size);
if (result != ASN1_SUCCESS)
{
err =
grub_error (GRUB_ERR_BAD_FILE_TYPE,
- "Error reading out UTF-8 string in DirectoryString: %s",
- asn1_strerror (result));
+ "Error reading out %s in DirectoryString: %s",
+ choice, asn1_strerror (result));
grub_free (*string);
goto cleanup_choice;
}
--
2.43.5