Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ppOXs-0002xx-Cu for mharc-grub-devel@gnu.org; Thu, 20 Apr 2023 03:17:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppOXl-0002vp-2J for grub-devel@gnu.org; Thu, 20 Apr 2023 03:17:25 -0400 Received: from mail-vi1eur05on2060.outbound.protection.outlook.com ([40.107.21.60] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppOXZ-0002As-TR for grub-devel@gnu.org; Thu, 20 Apr 2023 03:17:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a19Vv/+J6sNy20VirfGiTpkFC79+GNZaA9zOlJjbUx3ewsQO1/mT5AIDijb9zfb6+A/GiXUgS+se8vBx3qzGahH8pZHtXrGxOoFECnVO2wwrgSCL7ZYCFQBaGmGSE6jvLm5VImDcpRHuNnbsmsXxvP/+uJZIx3YgmioLtDT51Ouw/DeoxJ9AgsI6npdItW/9hqE56s/tuhuYQmCucBEmwczCHbYKmeoOVtuI+aQkaj/V675JDB3j2QVHs0NjSyZHHkWGCAmf9Sf5kHQXZ2wJ1yVdb7l0L327uP9plUEeuSi4OGmzIQQY6c24F5geBVsjv28O5uH5vbMAlnryNVLjAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UXPfPWg7WC7KMJZnWGXt7HzMdw/klSsAs4IRucvojxo=; b=bR8xYSMEus92/8BHVzInjSHj2UXbZvt95CVHd7ohEEbDxCMi5cObu3wm2iMXC+o2/VBBIgE1/W5G/ZhrC2hFAjJ8GPul+0kCTYWxxZrTOOWFGDb2/5knFS7BzBVQyBHcwX9T5lVCXsNUvOvnSYMtjW5LpG93xZyGjs09hM4SwW5i6ye+x91P3VVplLz2xU5oCQsLsKoukWeh++nnQvpsPxT3N/Utxi0p0xDbcvs/5zmTRwKQOfiFyPw7RE/olgvfS0N79Nq1/ZJxiqug5+AX/bi7js4shDe8SbZ3MZQarjrRCnAV/hfNPdSs3+L6lcy90WuBwqdBWplZ7MVAmpcBuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UXPfPWg7WC7KMJZnWGXt7HzMdw/klSsAs4IRucvojxo=; b=Boz6XDZHJ8AGouPbLQ0l/7lY6/HG5UjhH8DQ4nzpFwn0IOrXrtMvDGdqM7WbArR7mHoA1uTMVTrYAk9KMIa8DrL7drqOjesMOAjlM8L4eyKNlG6pdmjXKW8uIV1hq9B5nKXEaIsO9p4dKS2Rzn9LoOrFtqhR+UFRxLqlEvc9dk5b8rjaQysCQg8F4aV2+Bm0y+JKwnriEAAh6z59yY4RJFva2efXKGTVJVQGB97OHxZT+mOtvW1W4sh0bsb8a85OCD+Xt5BkhWgHJtpNoIWTzMY6BWAs3Ggw7vYqftYQd+iM75y0uotGRVJfz2f3IKkOnCjOAPBy2ULNlmKWpt3BwA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DBBPR04MB6140.eurprd04.prod.outlook.com (2603:10a6:10:c7::18) by DUZPR04MB9745.eurprd04.prod.outlook.com (2603:10a6:10:4e1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Thu, 20 Apr 2023 07:17:11 +0000 Received: from DBBPR04MB6140.eurprd04.prod.outlook.com ([fe80::dc0f:b8e1:84c9:2906]) by DBBPR04MB6140.eurprd04.prod.outlook.com ([fe80::dc0f:b8e1:84c9:2906%6]) with mapi id 15.20.6298.045; Thu, 20 Apr 2023 07:17:11 +0000 From: Gary Lin To: The development of GNU GRUB Cc: Hernan Gatta , Daniel Axtens , 'Daniel Kiper ' , shkhisti@microsoft.com, jaskaran.khurana@microsoft.com, christopher.co@microsoft.com, daniel.mihai@microsoft.com, rharwood@redhat.com, jaredz@redhat.com, development@efficientek.com, jejb@linux.ibm.com, mchang@suse.com Subject: [PATCH v4 07/12] libtasn1: Add the documentation Date: Thu, 20 Apr 2023 15:15:43 +0800 Message-Id: <20230420071548.28286-8-glin@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230420071548.28286-1-glin@suse.com> References: <20230420071548.28286-1-glin@suse.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYCP286CA0045.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:29d::19) To DBBPR04MB6140.eurprd04.prod.outlook.com (2603:10a6:10:c7::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6140:EE_|DUZPR04MB9745:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ca3bf77-1fef-4ad2-6999-08db416f424c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XUOLjhtR2q4jQF8D1Em0kVogDwKTcuVNnassfp5DHJWafKJ3X/G1dniCe3fBW5NRC0Sf5/Wz4sZQWGqw2smJtdCKIv+VVhYwlnQzeATjknwwkViEhewutpD2YYg94oPFseTySMFloQotkd7RkKaOG5u9DRb+djzZavsGDKUr/k3hagSiz1hqzWskP3CK9tP5RgiSy85S+zJFGHFka3BCR7wfdckMNufj2zz98sU8EX3fpXKxaZ7iOHKIKUjUJOb41LWZrVo5ZrE+tWYQJJE1bMcFLapmwxompifOYPXT+ArN7IALMKV8WeSMPwu4ypo6cmGvQncdrLONV8N4TtPtg8dbL8UPw/ymF6oTQUqIBeJT+CSYfd4WSHy2/jGh5Zju1P5L/2txlIFWhVwclPzreSwuN+wvdFKcHXdjs5dJEiXWiwLJL/FXHojflfr1S4DsKFKOuH+57xhbeasvx/o/c7CkDbXGCupA2uwMzIew1071bSRbTcZ2b9bv9ajvnVeqUODpnPNVd/+fMdM0Y307dEt2lpJV/72i+acrQSsXHfc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB6140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(136003)(366004)(376002)(346002)(396003)(39860400002)(451199021)(36756003)(6916009)(4326008)(54906003)(316002)(66946007)(66556008)(66476007)(966005)(186003)(478600001)(6486002)(6666004)(8936002)(5660300002)(41300700001)(8676002)(2906002)(7416002)(30864003)(86362001)(38100700002)(2616005)(6512007)(1076003)(26005)(107886003)(6506007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6gX3nWP2hx3HgLPSZuDjvOtyzD7ie7dEXC9zoxoowlZrc2S0r4eK6TDjPIZq?= =?us-ascii?Q?DDiAKKMSRK5P6qHvIljczSN7concSXX+6nxYmI/Y9DEizvNMdxcfIb5+QjN+?= =?us-ascii?Q?4JZPp88lGtqrw+U+9PYEsmTB9enZyyAEOBVGgDJ0S/0Vl5uCs6VFhQYvEDQR?= =?us-ascii?Q?j4CfKx+BsLJ4cOQzVSkLsgTRhjJux6+Zhkw7B+H2MWeiK7vI57t/x+v6COX4?= =?us-ascii?Q?5FJ68h9eVNEh6EW+q8XpWHzruTbDWIySfOxZC0IWzOzxv9lT8CcMfDN89Otx?= =?us-ascii?Q?IQuuNczt49f++fpYvKEd6cDgSwNKDrYpihLgLlPa5YPEfKnTZq5AyNGpbYmf?= =?us-ascii?Q?SmkyeFqS9ntLRXeVDHobQQAp9QpJmPu9iRTt+YQuujUQXAdH4YZ2+RW6bi7X?= =?us-ascii?Q?NxKNsT4Y1fDMZpZTJsH02ugNAysWYcQuZQ8pE26Inbp4L8yWGtNcVdex7cbX?= =?us-ascii?Q?MG4i9EVrB4cfynyTqdYy6RNwqBEuYkZsrT2LV/5ai4qDsH9tSpJ4uqTlW3Ak?= =?us-ascii?Q?vrdhZ1WJIVsO1JoksuwiXqLoPaY03p2Jj7rysQg0R6gw3bXHrcBsMoHTMy/Q?= =?us-ascii?Q?o9/Vk2IxgZ4NYuYXswxpxVJJU1AY6Eo9WYXTMZD4vynvnFsh9p29Vz/rUwTD?= =?us-ascii?Q?7L8Sb130r83l57TPII+9vcsV7jfCMlKnBgMQg/yZZT8I70pwgMMkIDp6yf5c?= =?us-ascii?Q?6ErUtZ3qerIT8YeNQxhBJN8+2hJV6ELnN0IRUU95uskAJAod8AtRiTZJeAyR?= =?us-ascii?Q?+M/J5hFK4UFGuomatTEqsMHoiKI/qOptV0IJrheu6nqEsLnhnpNoeyXsA36B?= =?us-ascii?Q?Ep3yOry/LTcr8Q/nufGWb7dRSqReZCsG/Gqy3Hp58fqSkWDJ92Zw1t+cmkrr?= =?us-ascii?Q?8tgdYbSrfJLSk+C3giM0uLraJ5Dcx6vXtA7MgUepkUoQt4WlKBzOyQPwk2MU?= =?us-ascii?Q?I8G41MAtrxIb6TAHNZT5T6Vdf1wwTC1lUSXrSLJT/FHOjfs2W294EtkdxtCl?= =?us-ascii?Q?mx8Ntz3N8ZpK3P/94fLNYoG1L25Y4PNbJtYDGg7WxY0rikVfDEv4GDFbLTnz?= =?us-ascii?Q?XQv80NQAJn7bufNQxICFFZmtOdYBP4KJ26Ahpw1+dflAFAitbzcACwOpy3Nw?= =?us-ascii?Q?PvO0TFl5ODYjDHZqS6HJLlcGd88hEvudMZwDXPKT2c70Ex/93GP0uXTxoWqT?= =?us-ascii?Q?eKbrlfA8jHqK08pn6lkihz6s82n3XQF32TfeVxtqIKJDKXJPlTYCxAUVHOKK?= =?us-ascii?Q?KwziGQi9g5oOPMjcGP7ouF89kLigcUCXe6+VozlsJnR7Tqqsw+WEC3EdDgPs?= =?us-ascii?Q?qmtIW+xE8rHjFpqoeb6XToW8DbY9lQHCg/n3kJLfwIFUKjF2IBAx+5jzh/H1?= =?us-ascii?Q?A4t5hwMamcGOVKunCxCqjnt2f+x7LSFXCW4ZJpkyD5vnyZzRze8yAWaa3YPG?= =?us-ascii?Q?eqOu1nka8Wwalx0T6fv8WIA+bQN2DgKwj90GfP0iAXljJais1upvW6+KUH30?= =?us-ascii?Q?7UfW/lH1ETm0swJgJsWtzJMjbFvOC0CyoWuac/62BU1iiNbHsNoXesUwQvl6?= =?us-ascii?Q?YfFAhbL/AYREYFty0sMCEw8wPDIQ1DFQwtd19xx2?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ca3bf77-1fef-4ad2-6999-08db416f424c X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2023 07:17:11.5994 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aTmkThqktcG0TvD0PNOvUm/0+ce9Q5bcv6HreGF4RnyE4HgseRRYGMA5WurcuBDE X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB9745 Received-SPF: pass client-ip=40.107.21.60; envelope-from=GLin@suse.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Apr 2023 07:17:27 -0000 Document libtasn1 in docs/grub-dev.texi and add the upgrade steps. Also add the patches to make libtasn1 compatible with grub code. Signed-off-by: Gary Lin --- docs/grub-dev.texi | 27 ++ ...asn1-disable-code-not-needed-in-grub.patch | 311 ++++++++++++++++++ ...tasn1-changes-for-grub-compatibility.patch | 209 ++++++++++++ 3 files changed, 547 insertions(+) create mode 100644 grub-core/lib/libtasn1-patches/0001-libtasn1-disable-code-not-needed-in-grub.patch create mode 100644 grub-core/lib/libtasn1-patches/0002-libtasn1-changes-for-grub-compatibility.patch diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index 31eb99ea2..702fe84f7 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -595,6 +595,33 @@ cp minilzo-2.10/*.[hc] grub-core/lib/minilzo rm -r minilzo-2.10* @end example +@node libtasn1 +@section libtasn1 + +libtasn1 is a library providing Abstract Syntax Notation One (ASN.1, as +specified by the X.680 ITU-T recommendation) parsing and structures management, +and Distinguished Encoding Rules (DER, as per X.690) encoding and decoding +functions. + +To upgrade to a new version of the libtasn1 library, download the release +tarball and copy the files into the target directory: + +@example +curl -L -O https://ftp.gnu.org/gnu/libtasn1/libtasn1-4.19.0.tar.gz +tar -zxf libtasn1-4.19.0.tar.gz +rm -r grub-core/lib/libtasn1/ +mkdir libtasn1/lib +mkdir -p grub-core/lib/libtasn1/lib/ +cp libtasn1-4.19.0/{README.md,COPYING} grub-core/lib/libtasn1/ +cp libtasn1-4.19.0/lib/{coding.c,decoding.c,element.c,element.h,errors.c,gstr.c,gstr.h,int.h,parser_aux.c,parser_aux.h,structure.c,structure.h} grub-core/lib/libtasn1/lib/ +cp libtasn1-4.19.0/lib/includes/libtasn1.h include/grub/ +rm -rf libtasn1-4.19.0 +@end example + +After upgrading the library, it is necessary to apply the patches in +@file{grub-core/lib/libtasn1-patches/} to adjust the code to be compatible with +grub. + @node Porting @chapter Porting diff --git a/grub-core/lib/libtasn1-patches/0001-libtasn1-disable-code-not-needed-in-grub.patch b/grub-core/lib/libtasn1-patches/0001-libtasn1-disable-code-not-needed-in-grub.patch new file mode 100644 index 000000000..4f116dda5 --- /dev/null +++ b/grub-core/lib/libtasn1-patches/0001-libtasn1-disable-code-not-needed-in-grub.patch @@ -0,0 +1,311 @@ +From c1c3459159d5d84e0d6da6eec6b86df5ccee1417 Mon Sep 17 00:00:00 2001 +From: Daniel Axtens +Date: Fri, 1 May 2020 17:12:23 +1000 +Subject: [PATCH 1/2] libtasn1: disable code not needed in grub + +We don't expect to be able to write ASN.1, only read it, +so we can disable some code. + +Do that with #if 0/#endif, rather than deletion. This means +that the difference between upstream and grub is smaller, +which should make updating libtasn1 easier in the future. + +With these exclusions we also avoid the need for minmax.h, +which is convenient because it means we don't have to +import it from gnulib. + +Signed-off-by: Daniel Axtens +Signed-off-by: Gary Lin +--- + grub-core/lib/libtasn1/lib/coding.c | 12 ++++++++++-- + grub-core/lib/libtasn1/lib/decoding.c | 2 ++ + grub-core/lib/libtasn1/lib/element.c | 4 ++-- + grub-core/lib/libtasn1/lib/errors.c | 3 +++ + grub-core/lib/libtasn1/lib/structure.c | 10 ++++++---- + include/grub/libtasn1.h | 15 +++++++++++++++ + 6 files changed, 38 insertions(+), 8 deletions(-) + +diff --git a/grub-core/lib/libtasn1/lib/coding.c b/grub-core/lib/libtasn1/lib/coding.c +index ea5bc370e..841fe47a9 100644 +--- a/grub-core/lib/libtasn1/lib/coding.c ++++ b/grub-core/lib/libtasn1/lib/coding.c +@@ -30,11 +30,11 @@ + #include "parser_aux.h" + #include + #include "element.h" +-#include "minmax.h" + #include + + #define MAX_TAG_LEN 16 + ++#if 0 + /******************************************************/ + /* Function : _asn1_error_description_value_not_found */ + /* Description: creates the ErrorDescription string */ +@@ -58,6 +58,7 @@ _asn1_error_description_value_not_found (asn1_node node, + Estrcat (ErrorDescription, "' not found"); + + } ++#endif + + /** + * asn1_length_der: +@@ -244,6 +245,7 @@ asn1_encode_simple_der (unsigned int etype, const unsigned char *str, + return ASN1_SUCCESS; + } + ++#if 0 + /******************************************************/ + /* Function : _asn1_time_der */ + /* Description: creates the DER coding for a TIME */ +@@ -278,7 +280,7 @@ _asn1_time_der (unsigned char *str, int str_len, unsigned char *der, + + return ASN1_SUCCESS; + } +- ++#endif + + /* + void +@@ -519,6 +521,7 @@ asn1_bit_der (const unsigned char *str, int bit_len, + } + + ++#if 0 + /******************************************************/ + /* Function : _asn1_complete_explicit_tag */ + /* Description: add the length coding to the EXPLICIT */ +@@ -595,6 +598,7 @@ _asn1_complete_explicit_tag (asn1_node node, unsigned char *der, + + return ASN1_SUCCESS; + } ++#endif + + const tag_and_class_st _asn1_tags[] = { + [ASN1_ETYPE_GENERALSTRING] = +@@ -647,6 +651,8 @@ const tag_and_class_st _asn1_tags[] = { + + unsigned int _asn1_tags_size = sizeof (_asn1_tags) / sizeof (_asn1_tags[0]); + ++ ++#if 0 + /******************************************************/ + /* Function : _asn1_insert_tag_der */ + /* Description: creates the DER coding of tags of one */ +@@ -1423,3 +1429,5 @@ error: + asn1_delete_structure (&node); + return err; + } ++ ++#endif +\ No newline at end of file +diff --git a/grub-core/lib/libtasn1/lib/decoding.c b/grub-core/lib/libtasn1/lib/decoding.c +index b9245c486..92fc87c23 100644 +--- a/grub-core/lib/libtasn1/lib/decoding.c ++++ b/grub-core/lib/libtasn1/lib/decoding.c +@@ -1620,6 +1620,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len, + return asn1_der_decoding2 (element, ider, &ider_len, 0, errorDescription); + } + ++#if 0 + /** + * asn1_der_decoding_element: + * @structure: pointer to an ASN1 structure +@@ -1650,6 +1651,7 @@ asn1_der_decoding_element (asn1_node * structure, const char *elementName, + { + return asn1_der_decoding (structure, ider, len, errorDescription); + } ++#endif + + /** + * asn1_der_decoding_startEnd: +diff --git a/grub-core/lib/libtasn1/lib/element.c b/grub-core/lib/libtasn1/lib/element.c +index d4c558e10..5c7941e53 100644 +--- a/grub-core/lib/libtasn1/lib/element.c ++++ b/grub-core/lib/libtasn1/lib/element.c +@@ -191,7 +191,7 @@ _asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache) + return ASN1_SUCCESS; + } + +- ++#if 0 + /** + * asn1_write_value: + * @node_root: pointer to a structure +@@ -646,7 +646,7 @@ asn1_write_value (asn1_node node_root, const char *name, + + return ASN1_SUCCESS; + } +- ++#endif + + #define PUT_VALUE( ptr, ptr_size, data, data_size) \ + *len = data_size; \ +diff --git a/grub-core/lib/libtasn1/lib/errors.c b/grub-core/lib/libtasn1/lib/errors.c +index aef5dfe6f..0175ddedb 100644 +--- a/grub-core/lib/libtasn1/lib/errors.c ++++ b/grub-core/lib/libtasn1/lib/errors.c +@@ -57,6 +57,8 @@ static const libtasn1_error_entry error_algorithms[] = { + {0, 0} + }; + ++ ++#if 0 + /** + * asn1_perror: + * @error: is an error returned by a libtasn1 function. +@@ -73,6 +75,7 @@ asn1_perror (int error) + const char *str = asn1_strerror (error); + fprintf (stderr, "LIBTASN1 ERROR: %s\n", str ? str : "(null)"); + } ++#endif + + /** + * asn1_strerror: +diff --git a/grub-core/lib/libtasn1/lib/structure.c b/grub-core/lib/libtasn1/lib/structure.c +index 512dd601f..3e1e35ba5 100644 +--- a/grub-core/lib/libtasn1/lib/structure.c ++++ b/grub-core/lib/libtasn1/lib/structure.c +@@ -76,7 +76,7 @@ _asn1_find_left (asn1_node_const node) + return node->left; + } + +- ++#if 0 + int + _asn1_create_static_structure (asn1_node_const pointer, + char *output_file_name, char *vector_name) +@@ -155,7 +155,7 @@ _asn1_create_static_structure (asn1_node_const pointer, + + return ASN1_SUCCESS; + } +- ++#endif + + /** + * asn1_array2tree: +@@ -721,7 +721,7 @@ asn1_create_element (asn1_node_const definitions, const char *source_name, + return res; + } + +- ++#if 0 + /** + * asn1_print_structure: + * @out: pointer to the output file (e.g. stdout). +@@ -1062,7 +1062,7 @@ asn1_print_structure (FILE * out, asn1_node_const structure, const char *name, + } + } + } +- ++#endif + + + /** +@@ -1158,6 +1158,7 @@ asn1_find_structure_from_oid (asn1_node_const definitions, + return NULL; /* ASN1_ELEMENT_NOT_FOUND; */ + } + ++#if 0 + /** + * asn1_copy_node: + * @dst: Destination asn1 node. +@@ -1207,6 +1208,7 @@ asn1_copy_node (asn1_node dst, const char *dst_name, + + return result; + } ++#endif + + /** + * asn1_dup_node: +diff --git a/include/grub/libtasn1.h b/include/grub/libtasn1.h +index 51cc7879f..507e0679e 100644 +--- a/include/grub/libtasn1.h ++++ b/include/grub/libtasn1.h +@@ -318,6 +318,8 @@ extern "C" + /* Functions definitions */ + /***********************************/ + ++/* These functions are not used in grub and should not be referenced. */ ++# if 0 + extern ASN1_API int + asn1_parser2tree (const char *file, + asn1_node * definitions, char *error_desc); +@@ -326,14 +328,17 @@ extern "C" + asn1_parser2array (const char *inputFileName, + const char *outputFileName, + const char *vectorName, char *error_desc); ++# endif + + extern ASN1_API int + asn1_array2tree (const asn1_static_node * array, + asn1_node * definitions, char *errorDescription); + ++# if 0 + extern ASN1_API void + asn1_print_structure (FILE * out, asn1_node_const structure, + const char *name, int mode); ++# endif + + extern ASN1_API int + asn1_create_element (asn1_node_const definitions, +@@ -347,9 +352,11 @@ extern "C" + extern ASN1_API int + asn1_delete_element (asn1_node structure, const char *element_name); + ++# if 0 + extern ASN1_API int + asn1_write_value (asn1_node node_root, const char *name, + const void *ivalue, int len); ++# endif + + extern ASN1_API int + asn1_read_value (asn1_node_const root, const char *name, +@@ -366,9 +373,11 @@ extern "C" + asn1_number_of_elements (asn1_node_const element, const char *name, + int *num); + ++# if 0 + extern ASN1_API int + asn1_der_coding (asn1_node_const element, const char *name, + void *ider, int *len, char *ErrorDescription); ++# endif + + extern ASN1_API int + asn1_der_decoding2 (asn1_node * element, const void *ider, +@@ -379,6 +388,7 @@ extern "C" + asn1_der_decoding (asn1_node * element, const void *ider, + int ider_len, char *errorDescription); + ++# if 0 + /* Do not use. Use asn1_der_decoding() instead. */ + extern ASN1_API int + asn1_der_decoding_element (asn1_node * structure, +@@ -386,6 +396,7 @@ extern "C" + const void *ider, int len, + char *errorDescription) + _ASN1_GCC_ATTR_DEPRECATED; ++# endif + + extern ASN1_API int + asn1_der_decoding_startEnd (asn1_node element, +@@ -411,12 +422,16 @@ extern "C" + const char + *oidValue); + ++# if 0 + __LIBTASN1_PURE__ + extern ASN1_API const char *asn1_check_version (const char *req_version); ++# endif + + __LIBTASN1_PURE__ extern ASN1_API const char *asn1_strerror (int error); + ++# if 0 + extern ASN1_API void asn1_perror (int error); ++# endif + + # define ASN1_MAX_TAG_SIZE 4 + # define ASN1_MAX_LENGTH_SIZE 9 +-- +2.35.3 + diff --git a/grub-core/lib/libtasn1-patches/0002-libtasn1-changes-for-grub-compatibility.patch b/grub-core/lib/libtasn1-patches/0002-libtasn1-changes-for-grub-compatibility.patch new file mode 100644 index 000000000..8547818da --- /dev/null +++ b/grub-core/lib/libtasn1-patches/0002-libtasn1-changes-for-grub-compatibility.patch @@ -0,0 +1,209 @@ +From 5d84feb27c073056739514bc0cb578fdf7cc5a90 Mon Sep 17 00:00:00 2001 +From: Daniel Axtens +Date: Fri, 1 May 2020 20:44:29 +1000 +Subject: [PATCH 2/2] libtasn1: changes for grub compatibility + +Do a few things to make libtasn1 compile as part of grub: + + - redefine _asn1_strcat. grub removed strcat so replace it with the + appropriate calls to memcpy and strlen. Use this internally where + strcat was used. + + - replace c_isdigit with grub_isdigit (and don't import c-ctype from + gnulib) grub_isdigit provides the same functionality as c_isdigit: it + determines if the input is an ASCII digit without regard for locale. + + - replace GL_ATTRIBUTE_PURE with __attribute__((pure)) which been + supported since gcc-2.96. This avoids messing around with gnulib. + + - adjust libtasn1.h: drop the ASN1_API logic, it's not needed for our + modules. Unconditionally support const and pure attributes and adjust + header paths. + + - adjust header paths to "grub/libtasn1.h". + + - replace a 64 bit division with a call to grub_divmod64, preventing + creation of __udivdi3 calls on 32 bit platforms. + +Signed-off-by: Daniel Axtens +Signed-off-by: Gary Lin +--- + grub-core/lib/libtasn1/lib/decoding.c | 11 +++++----- + grub-core/lib/libtasn1/lib/element.c | 3 ++- + grub-core/lib/libtasn1/lib/gstr.c | 4 ++-- + grub-core/lib/libtasn1/lib/int.h | 4 ++-- + grub-core/lib/libtasn1/lib/parser_aux.c | 7 +++--- + include/grub/libtasn1.h | 29 +++++++------------------ + 6 files changed, 24 insertions(+), 34 deletions(-) + +diff --git a/grub-core/lib/libtasn1/lib/decoding.c b/grub-core/lib/libtasn1/lib/decoding.c +index 92fc87c23..4fd5f0ce6 100644 +--- a/grub-core/lib/libtasn1/lib/decoding.c ++++ b/grub-core/lib/libtasn1/lib/decoding.c +@@ -32,7 +32,8 @@ + #include + #include + #include +-#include "c-ctype.h" ++ ++#define c_isdigit grub_isdigit + + #ifdef DEBUG + # define warn() fprintf(stderr, "%s: %d\n", __func__, __LINE__) +@@ -2016,8 +2017,8 @@ asn1_expand_octet_string (asn1_node_const definitions, asn1_node * element, + (p2->type & CONST_ASSIGN)) + { + strcpy (name, definitions->name); +- strcat (name, "."); +- strcat (name, p2->name); ++ _asn1_strcat (name, "."); ++ _asn1_strcat (name, p2->name); + + len = sizeof (value); + result = asn1_read_value (definitions, name, value, &len); +@@ -2034,8 +2035,8 @@ asn1_expand_octet_string (asn1_node_const definitions, asn1_node * element, + if (p2) + { + strcpy (name, definitions->name); +- strcat (name, "."); +- strcat (name, p2->name); ++ _asn1_strcat (name, "."); ++ _asn1_strcat (name, p2->name); + + result = asn1_create_element (definitions, name, &aux); + if (result == ASN1_SUCCESS) +diff --git a/grub-core/lib/libtasn1/lib/element.c b/grub-core/lib/libtasn1/lib/element.c +index 5c7941e53..822a1b6ab 100644 +--- a/grub-core/lib/libtasn1/lib/element.c ++++ b/grub-core/lib/libtasn1/lib/element.c +@@ -30,9 +30,10 @@ + #include "parser_aux.h" + #include + #include "structure.h" +-#include "c-ctype.h" + #include "element.h" + ++#define c_isdigit grub_isdigit ++ + void + _asn1_hierarchical_name (asn1_node_const node, char *name, int name_size) + { +diff --git a/grub-core/lib/libtasn1/lib/gstr.c b/grub-core/lib/libtasn1/lib/gstr.c +index eef419554..bc507d3d8 100644 +--- a/grub-core/lib/libtasn1/lib/gstr.c ++++ b/grub-core/lib/libtasn1/lib/gstr.c +@@ -36,13 +36,13 @@ _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src) + + if (dest_tot_size - dest_size > str_size) + { +- strcat (dest, src); ++ _asn1_strcat (dest, src); + } + else + { + if (dest_tot_size > dest_size) + { +- strncat (dest, src, (dest_tot_size - dest_size) - 1); ++ memcpy (dest + dest_size, src, (dest_tot_size - dest_size) - 1); + dest[dest_tot_size - 1] = 0; + } + } +diff --git a/grub-core/lib/libtasn1/lib/int.h b/grub-core/lib/libtasn1/lib/int.h +index d94d51c8c..07dd669ac 100644 +--- a/grub-core/lib/libtasn1/lib/int.h ++++ b/grub-core/lib/libtasn1/lib/int.h +@@ -35,7 +35,7 @@ + # include + # endif + +-# include ++# include "grub/libtasn1.h" + + # define ASN1_SMALL_VALUE_SIZE 16 + +@@ -115,7 +115,7 @@ extern const tag_and_class_st _asn1_tags[]; + # define _asn1_strtoul(n,e,b) strtoul((const char *) n, e, b) + # define _asn1_strcmp(a,b) strcmp((const char *)a, (const char *)b) + # define _asn1_strcpy(a,b) strcpy((char *)a, (const char *)b) +-# define _asn1_strcat(a,b) strcat((char *)a, (const char *)b) ++# define _asn1_strcat(a,b) memcpy((char *)a + strlen((const char *)a), (const char *)b, strlen((const char *)b) + 1) + + # if SIZEOF_UNSIGNED_LONG_INT == 8 + # define _asn1_strtou64(n,e,b) strtoul((const char *) n, e, b) +diff --git a/grub-core/lib/libtasn1/lib/parser_aux.c b/grub-core/lib/libtasn1/lib/parser_aux.c +index c05bd2339..8bdc42ae3 100644 +--- a/grub-core/lib/libtasn1/lib/parser_aux.c ++++ b/grub-core/lib/libtasn1/lib/parser_aux.c +@@ -26,7 +26,8 @@ + #include "gstr.h" + #include "structure.h" + #include "element.h" +-#include "c-ctype.h" ++ ++#define c_isdigit grub_isdigit + + char _asn1_identifierMissing[ASN1_MAX_NAME_SIZE + 1]; /* identifier name not found */ + +@@ -40,7 +41,7 @@ char _asn1_identifierMissing[ASN1_MAX_NAME_SIZE + 1]; /* identifier name not fou + #ifdef __clang__ + __attribute__((no_sanitize ("integer"))) + #endif +- _GL_ATTRIBUTE_PURE static unsigned int _asn1_hash_name (const char *x) ++ __attribute__((__pure__)) static unsigned int _asn1_hash_name (const char *x) + { + const unsigned char *s = (unsigned char *) x; + unsigned h = 0; +@@ -632,7 +633,7 @@ _asn1_ltostr (int64_t v, char str[LTOSTR_MAX_SIZE]) + count = 0; + do + { +- d = val / 10; ++ d = grub_divmod64(val, 10, NULL); + r = val - d * 10; + temp[start + count] = '0' + (char) r; + count++; +diff --git a/include/grub/libtasn1.h b/include/grub/libtasn1.h +index 507e0679e..201089c11 100644 +--- a/include/grub/libtasn1.h ++++ b/include/grub/libtasn1.h +@@ -34,29 +34,16 @@ + #ifndef LIBTASN1_H + # define LIBTASN1_H + +-# ifndef ASN1_API +-# if defined ASN1_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY +-# define ASN1_API __attribute__((__visibility__("default"))) +-# elif defined ASN1_BUILDING && defined _MSC_VER && ! defined ASN1_STATIC +-# define ASN1_API __declspec(dllexport) +-# elif defined _MSC_VER && ! defined ASN1_STATIC +-# define ASN1_API __declspec(dllimport) +-# else +-# define ASN1_API +-# endif +-# endif ++/* grub: ASN1_API is not used */ ++# define ASN1_API ++ ++/* grub: all our supported compilers support these attributes */ ++# define __LIBTASN1_CONST__ __attribute__((const)) ++# define __LIBTASN1_PURE__ __attribute__((pure)) + +-# ifdef __GNUC__ +-# define __LIBTASN1_CONST__ __attribute__((const)) +-# define __LIBTASN1_PURE__ __attribute__((pure)) +-# else +-# define __LIBTASN1_CONST__ +-# define __LIBTASN1_PURE__ +-# endif + +-# include +-# include +-# include /* for FILE* */ ++# include ++# include + + # ifdef __cplusplus + extern "C" +-- +2.35.3 + -- 2.35.3