nalika / rpms / grub2

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