1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
|
From f534b3c0902adf207b7e51b8364284fe6a06731b Mon Sep 17 00:00:00 2001
From: Daniel Axtens <dja@axtens.net>
Date: Fri, 1 May 2020 17:12:23 +1000
Subject: [PATCH 01/13] 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 <dja@axtens.net>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
grub-core/lib/libtasn1-grub/lib/coding.c | 12 ++++++++++--
grub-core/lib/libtasn1-grub/lib/decoding.c | 2 ++
grub-core/lib/libtasn1-grub/lib/element.c | 6 +++---
grub-core/lib/libtasn1-grub/lib/errors.c | 3 +++
grub-core/lib/libtasn1-grub/lib/structure.c | 10 ++++++----
grub-core/lib/libtasn1-grub/libtasn1.h | 15 +++++++++++++++
6 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/grub-core/lib/libtasn1-grub/lib/coding.c b/grub-core/lib/libtasn1-grub/lib/coding.c
index ea5bc370e..5d03bca9d 100644
--- a/grub-core/lib/libtasn1-grub/lib/coding.c
+++ b/grub-core/lib/libtasn1-grub/lib/coding.c
@@ -30,11 +30,11 @@
#include "parser_aux.h"
#include <gstr.h>
#include "element.h"
-#include "minmax.h"
#include <structure.h>
#define MAX_TAG_LEN 16
+#if 0 /* GRUB SKIPPED IMPORTING */
/******************************************************/
/* 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 /* GRUB SKIPPED IMPORTING */
/******************************************************/
/* 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 /* GRUB SKIPPED IMPORTING */
/******************************************************/
/* 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 /* GRUB SKIPPED IMPORTING */
/******************************************************/
/* 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
diff --git a/grub-core/lib/libtasn1-grub/lib/decoding.c b/grub-core/lib/libtasn1-grub/lib/decoding.c
index b9245c486..bf9cb13ac 100644
--- a/grub-core/lib/libtasn1-grub/lib/decoding.c
+++ b/grub-core/lib/libtasn1-grub/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 /* GRUB SKIPPED IMPORTING */
/**
* 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-grub/lib/element.c b/grub-core/lib/libtasn1-grub/lib/element.c
index d4c558e10..bc4c3c8d7 100644
--- a/grub-core/lib/libtasn1-grub/lib/element.c
+++ b/grub-core/lib/libtasn1-grub/lib/element.c
@@ -118,7 +118,7 @@ _asn1_convert_integer (const unsigned char *value, unsigned char *value_out,
value_out[k2 - k] = val[k2];
}
-#if 0
+#if 0 /* GRUB SKIPPED IMPORTING */
printf ("_asn1_convert_integer: valueIn=%s, lenOut=%d", value, *len);
for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
printf (", vOut[%d]=%d", k, value_out[k]);
@@ -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-grub/lib/errors.c b/grub-core/lib/libtasn1-grub/lib/errors.c
index aef5dfe6f..2b2322152 100644
--- a/grub-core/lib/libtasn1-grub/lib/errors.c
+++ b/grub-core/lib/libtasn1-grub/lib/errors.c
@@ -57,6 +57,8 @@ static const libtasn1_error_entry error_algorithms[] = {
{0, 0}
};
+
+#if 0 /* GRUB SKIPPED IMPORTING */
/**
* 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-grub/lib/structure.c b/grub-core/lib/libtasn1-grub/lib/structure.c
index 512dd601f..f5a947d57 100644
--- a/grub-core/lib/libtasn1-grub/lib/structure.c
+++ b/grub-core/lib/libtasn1-grub/lib/structure.c
@@ -76,7 +76,7 @@ _asn1_find_left (asn1_node_const node)
return node->left;
}
-
+#if 0 /* GRUB SKIPPED IMPORTING */
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 /* GRUB SKIPPED IMPORTING */
/**
* 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 /* GRUB SKIPPED IMPORTING */
/**
* 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/grub-core/lib/libtasn1-grub/libtasn1.h b/grub-core/lib/libtasn1-grub/libtasn1.h
index 51cc7879f..058ab27b0 100644
--- a/grub-core/lib/libtasn1-grub/libtasn1.h
+++ b/grub-core/lib/libtasn1-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 /* GRUB SKIPPED IMPORTING */
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 /* GRUB SKIPPED IMPORTING */
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 /* GRUB SKIPPED IMPORTING */
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 /* GRUB SKIPPED IMPORTING */
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 /* GRUB SKIPPED IMPORTING */
/* 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 /* GRUB SKIPPED IMPORTING */
__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 /* GRUB SKIPPED IMPORTING */
extern ASN1_API void asn1_perror (int error);
+# endif
# define ASN1_MAX_TAG_SIZE 4
# define ASN1_MAX_LENGTH_SIZE 9
--
2.43.0
|