Blame SOURCES/0360-libtasn1-disable-code-not-needed-in-grub.patch

3efed6
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
3efed6
From: Daniel Axtens <dja@axtens.net>
3efed6
Date: Fri, 1 May 2020 17:12:23 +1000
3efed6
Subject: [PATCH] libtasn1: disable code not needed in grub
3efed6
3efed6
We don't expect to be able to write ASN.1, only read it,
3efed6
so we can disable some code.
3efed6
3efed6
Do that with #if 0/#endif, rather than deletion. This means
3efed6
that the difference between upstream and grub is smaller,
3efed6
which should make updating libtasn1 easier in the future.
3efed6
3efed6
With these exclusions we also avoid the need for minmax.h,
3efed6
which is convenient because it means we don't have to
3efed6
import it from gnulib.
3efed6
3efed6
Signed-off-by: Daniel Axtens <dja@axtens.net>
3efed6
---
3efed6
 grub-core/lib/libtasn1/lib/coding.c    | 12 ++++++++++--
3efed6
 grub-core/lib/libtasn1/lib/decoding.c  |  2 ++
3efed6
 grub-core/lib/libtasn1/lib/element.c   |  4 ++--
3efed6
 grub-core/lib/libtasn1/lib/errors.c    |  3 +++
3efed6
 grub-core/lib/libtasn1/lib/structure.c | 10 ++++++----
3efed6
 include/grub/libtasn1.h                | 15 +++++++++++++++
3efed6
 6 files changed, 38 insertions(+), 8 deletions(-)
3efed6
3efed6
diff --git a/grub-core/lib/libtasn1/lib/coding.c b/grub-core/lib/libtasn1/lib/coding.c
b71686
index 245ea64cf..52def5983 100644
3efed6
--- a/grub-core/lib/libtasn1/lib/coding.c
3efed6
+++ b/grub-core/lib/libtasn1/lib/coding.c
3efed6
@@ -30,11 +30,11 @@
3efed6
 #include "parser_aux.h"
3efed6
 #include <gstr.h>
3efed6
 #include "element.h"
3efed6
-#include "minmax.h"
3efed6
 #include <structure.h>
3efed6
 
3efed6
 #define MAX_TAG_LEN 16
3efed6
 
3efed6
+#if 0
3efed6
 /******************************************************/
3efed6
 /* Function : _asn1_error_description_value_not_found */
3efed6
 /* Description: creates the ErrorDescription string   */
3efed6
@@ -58,6 +58,7 @@ _asn1_error_description_value_not_found (asn1_node node,
3efed6
   Estrcat (ErrorDescription, "' not found");
3efed6
 
3efed6
 }
3efed6
+#endif
3efed6
 
3efed6
 /**
3efed6
  * asn1_length_der:
3efed6
@@ -244,6 +245,7 @@ asn1_encode_simple_der (unsigned int etype, const unsigned char *str,
3efed6
   return ASN1_SUCCESS;
3efed6
 }
3efed6
 
3efed6
+#if 0
3efed6
 /******************************************************/
3efed6
 /* Function : _asn1_time_der                          */
3efed6
 /* Description: creates the DER coding for a TIME     */
3efed6
@@ -281,7 +283,7 @@ _asn1_time_der (unsigned char *str, int str_len, unsigned char *der,
3efed6
 
3efed6
   return ASN1_SUCCESS;
3efed6
 }
3efed6
-
3efed6
+#endif
3efed6
 
3efed6
 /*
3efed6
 void
3efed6
@@ -520,6 +522,7 @@ asn1_bit_der (const unsigned char *str, int bit_len,
3efed6
 }
3efed6
 
3efed6
 
3efed6
+#if 0
3efed6
 /******************************************************/
3efed6
 /* Function : _asn1_complete_explicit_tag             */
3efed6
 /* Description: add the length coding to the EXPLICIT */
3efed6
@@ -596,6 +599,7 @@ _asn1_complete_explicit_tag (asn1_node node, unsigned char *der,
3efed6
 
3efed6
   return ASN1_SUCCESS;
3efed6
 }
3efed6
+#endif
3efed6
 
3efed6
 const tag_and_class_st _asn1_tags[] = {
3efed6
   [ASN1_ETYPE_GENERALSTRING] =
3efed6
@@ -648,6 +652,8 @@ const tag_and_class_st _asn1_tags[] = {
3efed6
 
3efed6
 unsigned int _asn1_tags_size = sizeof (_asn1_tags) / sizeof (_asn1_tags[0]);
3efed6
 
3efed6
+
3efed6
+#if 0
3efed6
 /******************************************************/
3efed6
 /* Function : _asn1_insert_tag_der                    */
3efed6
 /* Description: creates the DER coding of tags of one */
3efed6
@@ -1413,3 +1419,5 @@ error:
3efed6
   asn1_delete_structure (&node);
3efed6
   return err;
3efed6
 }
3efed6
+
3efed6
+#endif
3efed6
\ No newline at end of file
3efed6
diff --git a/grub-core/lib/libtasn1/lib/decoding.c b/grub-core/lib/libtasn1/lib/decoding.c
b71686
index ff04eb778..42f9a92b5 100644
3efed6
--- a/grub-core/lib/libtasn1/lib/decoding.c
3efed6
+++ b/grub-core/lib/libtasn1/lib/decoding.c
3efed6
@@ -1613,6 +1613,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
3efed6
   return asn1_der_decoding2 (element, ider, &ider_len, 0, errorDescription);
3efed6
 }
3efed6
 
3efed6
+#if 0
3efed6
 /**
3efed6
  * asn1_der_decoding_element:
3efed6
  * @structure: pointer to an ASN1 structure
3efed6
@@ -1643,6 +1644,7 @@ asn1_der_decoding_element (asn1_node * structure, const char *elementName,
3efed6
 {
3efed6
   return asn1_der_decoding(structure, ider, len, errorDescription);
3efed6
 }
3efed6
+#endif
3efed6
 
3efed6
 /**
3efed6
  * asn1_der_decoding_startEnd:
3efed6
diff --git a/grub-core/lib/libtasn1/lib/element.c b/grub-core/lib/libtasn1/lib/element.c
b71686
index 997eb2725..539008d8e 100644
3efed6
--- a/grub-core/lib/libtasn1/lib/element.c
3efed6
+++ b/grub-core/lib/libtasn1/lib/element.c
3efed6
@@ -191,7 +191,7 @@ _asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache)
3efed6
   return ASN1_SUCCESS;
3efed6
 }
3efed6
 
3efed6
-
3efed6
+#if 0
3efed6
 /**
3efed6
  * asn1_write_value:
3efed6
  * @node_root: pointer to a structure
3efed6
@@ -645,7 +645,7 @@ asn1_write_value (asn1_node node_root, const char *name,
3efed6
 
3efed6
   return ASN1_SUCCESS;
3efed6
 }
3efed6
-
3efed6
+#endif
3efed6
 
3efed6
 #define PUT_VALUE( ptr, ptr_size, data, data_size) \
3efed6
 	*len = data_size; \
3efed6
diff --git a/grub-core/lib/libtasn1/lib/errors.c b/grub-core/lib/libtasn1/lib/errors.c
b71686
index cee74daf7..42785e862 100644
3efed6
--- a/grub-core/lib/libtasn1/lib/errors.c
3efed6
+++ b/grub-core/lib/libtasn1/lib/errors.c
3efed6
@@ -57,6 +57,8 @@ static const libtasn1_error_entry error_algorithms[] = {
3efed6
   {0, 0}
3efed6
 };
3efed6
 
3efed6
+
3efed6
+#if 0
3efed6
 /**
3efed6
  * asn1_perror:
3efed6
  * @error: is an error returned by a libtasn1 function.
3efed6
@@ -73,6 +75,7 @@ asn1_perror (int error)
3efed6
   const char *str = asn1_strerror (error);
3efed6
   fprintf (stderr, "LIBTASN1 ERROR: %s\n", str ? str : "(null)");
3efed6
 }
3efed6
+#endif
3efed6
 
3efed6
 /**
3efed6
  * asn1_strerror:
3efed6
diff --git a/grub-core/lib/libtasn1/lib/structure.c b/grub-core/lib/libtasn1/lib/structure.c
b71686
index 8189c56a4..fcfde01a3 100644
3efed6
--- a/grub-core/lib/libtasn1/lib/structure.c
3efed6
+++ b/grub-core/lib/libtasn1/lib/structure.c
3efed6
@@ -76,7 +76,7 @@ _asn1_find_left (asn1_node_const node)
3efed6
   return node->left;
3efed6
 }
3efed6
 
3efed6
-
3efed6
+#if 0
3efed6
 int
3efed6
 _asn1_create_static_structure (asn1_node_const pointer, char *output_file_name,
3efed6
 			       char *vector_name)
3efed6
@@ -155,7 +155,7 @@ _asn1_create_static_structure (asn1_node_const pointer, char *output_file_name,
3efed6
 
3efed6
   return ASN1_SUCCESS;
3efed6
 }
3efed6
-
3efed6
+#endif
3efed6
 
3efed6
 /**
3efed6
  * asn1_array2tree:
3efed6
@@ -718,7 +718,7 @@ asn1_create_element (asn1_node_const definitions, const char *source_name,
3efed6
   return res;
3efed6
 }
3efed6
 
3efed6
-
3efed6
+#if 0
3efed6
 /**
3efed6
  * asn1_print_structure:
3efed6
  * @out: pointer to the output file (e.g. stdout).
3efed6
@@ -1058,7 +1058,7 @@ asn1_print_structure (FILE * out, asn1_node_const structure, const char *name,
3efed6
 	}
3efed6
     }
3efed6
 }
3efed6
-
3efed6
+#endif
3efed6
 
3efed6
 
3efed6
 /**
3efed6
@@ -1153,6 +1153,7 @@ asn1_find_structure_from_oid (asn1_node_const definitions, const char *oidValue)
3efed6
   return NULL;			/* ASN1_ELEMENT_NOT_FOUND; */
3efed6
 }
3efed6
 
3efed6
+#if 0
3efed6
 /**
3efed6
  * asn1_copy_node:
3efed6
  * @dst: Destination asn1 node.
3efed6
@@ -1202,6 +1203,7 @@ asn1_copy_node (asn1_node dst, const char *dst_name,
3efed6
 
3efed6
   return result;
3efed6
 }
3efed6
+#endif
3efed6
 
3efed6
 /**
3efed6
  * asn1_dup_node:
3efed6
diff --git a/include/grub/libtasn1.h b/include/grub/libtasn1.h
b71686
index 6fd7a30dc..785eda2ae 100644
3efed6
--- a/include/grub/libtasn1.h
3efed6
+++ b/include/grub/libtasn1.h
3efed6
@@ -319,6 +319,8 @@ typedef struct asn1_data_node_st asn1_data_node_st;
3efed6
 /*  Functions definitions          */
3efed6
 /***********************************/
3efed6
 
3efed6
+/* These functions are not used in grub and should not be referenced. */
3efed6
+#if 0
3efed6
 extern ASN1_API int
3efed6
   asn1_parser2tree (const char *file,
3efed6
 		      asn1_node * definitions, char *error_desc);
3efed6
@@ -327,14 +329,17 @@ extern ASN1_API int
3efed6
   asn1_parser2array (const char *inputFileName,
3efed6
 		       const char *outputFileName,
3efed6
 		       const char *vectorName, char *error_desc);
3efed6
+#endif
3efed6
 
3efed6
 extern ASN1_API int
3efed6
   asn1_array2tree (const asn1_static_node * array,
3efed6
 		     asn1_node * definitions, char *errorDescription);
3efed6
 
3efed6
+#if 0
3efed6
 extern ASN1_API void
3efed6
   asn1_print_structure (FILE * out, asn1_node_const structure,
3efed6
 			  const char *name, int mode);
3efed6
+#endif
3efed6
 
3efed6
 extern ASN1_API int
3efed6
   asn1_create_element (asn1_node_const definitions,
3efed6
@@ -347,9 +352,11 @@ extern ASN1_API int asn1_delete_structure2 (asn1_node * structure, unsigned int
3efed6
 extern ASN1_API int
3efed6
   asn1_delete_element (asn1_node structure, const char *element_name);
3efed6
 
3efed6
+#if 0
3efed6
 extern ASN1_API int
3efed6
   asn1_write_value (asn1_node node_root, const char *name,
3efed6
 		      const void *ivalue, int len);
3efed6
+#endif
3efed6
 
3efed6
 extern ASN1_API int
3efed6
   asn1_read_value (asn1_node_const root, const char *name,
3efed6
@@ -365,9 +372,11 @@ extern ASN1_API int
3efed6
 extern ASN1_API int
3efed6
   asn1_number_of_elements (asn1_node_const element, const char *name, int *num);
3efed6
 
3efed6
+#if 0
3efed6
 extern ASN1_API int
3efed6
   asn1_der_coding (asn1_node_const element, const char *name,
3efed6
 		     void *ider, int *len, char *ErrorDescription);
3efed6
+#endif
3efed6
 
3efed6
 extern ASN1_API int
3efed6
   asn1_der_decoding2 (asn1_node *element, const void *ider,
3efed6
@@ -378,12 +387,14 @@ extern ASN1_API int
3efed6
   asn1_der_decoding (asn1_node * element, const void *ider,
3efed6
 		       int ider_len, char *errorDescription);
3efed6
 
3efed6
+#if 0
3efed6
 /* Do not use. Use asn1_der_decoding() instead. */
3efed6
 extern ASN1_API int
3efed6
   asn1_der_decoding_element (asn1_node * structure,
3efed6
 			       const char *elementName,
3efed6
 			       const void *ider, int len,
3efed6
 			       char *errorDescription) _ASN1_GCC_ATTR_DEPRECATED;
3efed6
+#endif
3efed6
 
3efed6
 extern ASN1_API int
3efed6
   asn1_der_decoding_startEnd (asn1_node element,
3efed6
@@ -408,13 +419,17 @@ extern ASN1_API const char *asn1_find_structure_from_oid (asn1_node_const
3efed6
 							    const char
3efed6
 							    *oidValue);
3efed6
 
3efed6
+#if 0
3efed6
 __LIBTASN1_PURE__
3efed6
 extern ASN1_API const char *asn1_check_version (const char *req_version);
3efed6
+#endif
3efed6
 
3efed6
 __LIBTASN1_PURE__
3efed6
 extern ASN1_API const char *asn1_strerror (int error);
3efed6
 
3efed6
+#if 0
3efed6
 extern ASN1_API void asn1_perror (int error);
3efed6
+#endif
3efed6
 
3efed6
 #define ASN1_MAX_TAG_SIZE 4
3efed6
 #define ASN1_MAX_LENGTH_SIZE 9