File: 0011-asn1_test-print-the-error-messages-with-grub_printf.patch

package info (click to toggle)
grub2 2.14~git20250718.0e36779-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 60,688 kB
  • sloc: ansic: 541,811; asm: 68,074; sh: 9,803; cpp: 2,095; makefile: 1,895; python: 1,518; sed: 446; lex: 393; yacc: 268; awk: 85; lisp: 54; perl: 31
file content (485 lines) | stat: -rw-r--r-- 17,117 bytes parent folder | download
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
From af5f0a651de09e44e78177b988857acd3208c4b6 Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Fri, 16 Aug 2024 15:00:42 +0800
Subject: [PATCH 11/13] asn1_test: print the error messages with grub_printf()

This commit replaces printf() and fprintf() with grub_printf() to print
the error messages for the testcases. Besides, asn1_strerror() is used
to convert the result code to strings instead of asn1_perror().

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/tests/asn1/tests/CVE-2018-1000654.c |  8 +--
 grub-core/tests/asn1/tests/Test_overflow.c    | 14 ++---
 grub-core/tests/asn1/tests/Test_simple.c      | 21 ++++----
 grub-core/tests/asn1/tests/Test_strings.c     | 21 +++-----
 .../tests/asn1/tests/object-id-decoding.c     | 16 +++---
 .../tests/asn1/tests/object-id-encoding.c     | 26 ++++-----
 grub-core/tests/asn1/tests/octet-string.c     | 54 ++++++++-----------
 grub-core/tests/asn1/tests/reproducers.c      |  6 +--
 8 files changed, 67 insertions(+), 99 deletions(-)

diff --git a/grub-core/tests/asn1/tests/CVE-2018-1000654.c b/grub-core/tests/asn1/tests/CVE-2018-1000654.c
index 81448cde8..b78667900 100644
--- a/grub-core/tests/asn1/tests/CVE-2018-1000654.c
+++ b/grub-core/tests/asn1/tests/CVE-2018-1000654.c
@@ -38,8 +38,8 @@ test_CVE_2018_1000654 (void)
 		     errorDescription);
   if (result != ASN1_RECURSION)
     {
-      asn1_perror (result);
-      printf ("ErrorDescription = %s\n\n", errorDescription);
+      grub_printf ("Error: %s\nErrorDescription = %s\n\n",
+		   asn1_strerror (result), errorDescription);
       return 1;
     }
 
@@ -50,8 +50,8 @@ test_CVE_2018_1000654 (void)
 		     errorDescription);
   if (result != ASN1_RECURSION)
     {
-      asn1_perror (result);
-      printf ("ErrorDescription = %s\n\n", errorDescription);
+      grub_printf ("Error: %s\nErrorDescription = %s\n\n",
+		   asn1_strerror (result), errorDescription);
       return 1;
     }
 
diff --git a/grub-core/tests/asn1/tests/Test_overflow.c b/grub-core/tests/asn1/tests/Test_overflow.c
index 9f9578a1f..ffac8507a 100644
--- a/grub-core/tests/asn1/tests/Test_overflow.c
+++ b/grub-core/tests/asn1/tests/Test_overflow.c
@@ -36,7 +36,7 @@ test_overflow (void)
 
     if (l != -2L)
       {
-	printf ("ERROR: asn1_get_length_der bignum (l %ld len %d)\n", l, len);
+	grub_printf ("ERROR: asn1_get_length_der bignum (l %ld len %d)\n", l, len);
 	return 1;
       }
   }
@@ -57,8 +57,7 @@ test_overflow (void)
 
       if (l != -2L)
 	{
-	  printf ("ERROR: asn1_get_length_der intnum (l %ld len %d)\n", l,
-		  len);
+	  grub_printf ("ERROR: asn1_get_length_der intnum (l %ld len %d)\n", l, len);
 	  return 1;
 	}
     }
@@ -79,8 +78,7 @@ test_overflow (void)
 
     if (l != -4L)
       {
-	printf ("ERROR: asn1_get_length_der overflow-small (l %ld len %d)\n",
-		l, len);
+	grub_printf ("ERROR: asn1_get_length_der overflow-small (l %ld len %d)\n", l, len);
 	return 1;
       }
   }
@@ -101,8 +99,7 @@ test_overflow (void)
 
     if (l != -4L)
       {
-	printf ("ERROR: asn1_get_length_der overflow-large1 (l %ld len %d)\n",
-		l, len);
+	grub_printf ("ERROR: asn1_get_length_der overflow-large1 (l %ld len %d)\n", l, len);
 	return 1;
       }
   }
@@ -123,8 +120,7 @@ test_overflow (void)
 
     if (l != -2L)
       {
-	printf ("ERROR: asn1_get_length_der overflow-large2 (l %ld len %d)\n",
-		l, len);
+	grub_printf ("ERROR: asn1_get_length_der overflow-large2 (l %ld len %d)\n", l, len);
 	return 1;
       }
   }
diff --git a/grub-core/tests/asn1/tests/Test_simple.c b/grub-core/tests/asn1/tests/Test_simple.c
index 12993bfba..dc70db191 100644
--- a/grub-core/tests/asn1/tests/Test_simple.c
+++ b/grub-core/tests/asn1/tests/Test_simple.c
@@ -94,7 +94,7 @@ test_simple (void)
     result = asn1_encode_simple_der (etype, my_str, my_str_len, tl, &tl_len);
     if (result != ASN1_VALUE_NOT_VALID)
       {
-	fprintf (stderr, "asn1_encode_simple_der out of range etype\n");
+	grub_printf ("asn1_encode_simple_der out of range etype\n");
 	return 1;
       }
   }
@@ -105,7 +105,7 @@ test_simple (void)
   result = asn1_get_bit_der (der, 0, &ret_len, str, str_size, &bit_len);
   if (result != ASN1_GENERIC_ERROR)
     {
-      fprintf (stderr, "asn1_get_bit_der zero\n");
+      grub_printf ("asn1_get_bit_der zero\n");
       return 1;
     }
 
@@ -129,7 +129,7 @@ test_simple (void)
 
       if (der_len != tv[i].derlen || memcmp (der, tv[i].der, der_len) != 0)
 	{
-	  fprintf (stderr, "asn1_bit_der iter %lu\n", (unsigned long) i);
+	  grub_printf ("asn1_bit_der iter %lu\n", (unsigned long) i);
 	  return 1;
 	}
 
@@ -140,8 +140,7 @@ test_simple (void)
       if (result != ASN1_SUCCESS || ret_len != tv[i].derlen
 	  || bit_len != tv[i].bitlen)
 	{
-	  fprintf (stderr, "asn1_get_bit_der iter %lu, err: %d\n",
-		   (unsigned long) i, result);
+	  grub_printf ("asn1_get_bit_der iter %lu, err: %d\n", (unsigned long) i, result);
 	  return 1;
 	}
     }
@@ -163,7 +162,7 @@ test_simple (void)
   if (result != ASN1_SUCCESS || ret_len != 5
       || bit_len != 18 || memcmp (str, "\x6e\x5d\xc0", 3) != 0)
     {
-      fprintf (stderr, "asn1_get_bit_der example\n");
+      grub_printf ("asn1_get_bit_der example\n");
       return 1;
     }
 
@@ -171,7 +170,7 @@ test_simple (void)
   asn1_bit_der (str, bit_len, der, &der_len);
   if (der_len != 5 || memcmp (der, "\x04\x06\x6e\x5d\xc0", 5) != 0)
     {
-      fprintf (stderr, "asn1_bit_der example roundtrip\n");
+      grub_printf ("asn1_bit_der example roundtrip\n");
       return 1;
     }
 
@@ -184,7 +183,7 @@ test_simple (void)
   if (result != ASN1_SUCCESS || ret_len != 5
       || bit_len != 18 || memcmp (str, "\x6e\x5d\xe0", 3) != 0)
     {
-      fprintf (stderr, "asn1_get_bit_der example padded\n");
+      grub_printf ("asn1_get_bit_der example padded\n");
       return 1;
     }
 
@@ -192,7 +191,7 @@ test_simple (void)
   asn1_bit_der (str, bit_len, der, &der_len);
   if (der_len != 5 || memcmp (der, "\x04\x06\x6e\x5d\xc0", 5) != 0)
     {
-      fprintf (stderr, "asn1_bit_der example roundtrip\n");
+      grub_printf ("asn1_bit_der example roundtrip\n");
       return 1;
     }
 
@@ -206,7 +205,7 @@ test_simple (void)
   if (result != ASN1_SUCCESS || ret_len != 6
       || bit_len != 18 || memcmp (str, "\x6e\x5d\xc0", 3) != 0)
     {
-      fprintf (stderr, "asn1_get_bit_der example long form\n");
+      grub_printf ("asn1_get_bit_der example long form\n");
       return 1;
     }
 
@@ -214,7 +213,7 @@ test_simple (void)
   asn1_bit_der (str, bit_len, der, &der_len);
   if (der_len != 5 || memcmp (der, "\x04\x06\x6e\x5d\xc0", 5) != 0)
     {
-      fprintf (stderr, "asn1_bit_der example roundtrip\n");
+      grub_printf ("asn1_bit_der example roundtrip\n");
       return 1;
     }
 
diff --git a/grub-core/tests/asn1/tests/Test_strings.c b/grub-core/tests/asn1/tests/Test_strings.c
index 2538f2558..65c30937f 100644
--- a/grub-core/tests/asn1/tests/Test_strings.c
+++ b/grub-core/tests/asn1/tests/Test_strings.c
@@ -89,17 +89,14 @@ test_strings (void)
 				    tl, &tl_len);
       if (ret != ASN1_SUCCESS)
 	{
-	  fprintf (stderr, "Encoding error in %u: %s\n", i,
-		   asn1_strerror (ret));
+	  grub_printf ("Encoding error in %u: %s\n", i, asn1_strerror (ret));
 	  return 1;
 	}
       der_len = tl_len + tv[i].str_len;
 
       if (der_len != tv[i].der_len || memcmp (tl, tv[i].der, tl_len) != 0)
 	{
-	  fprintf (stderr,
-		   "DER encoding differs in %u! (size: %u, expected: %u)\n",
-		   i, der_len, tv[i].der_len);
+	  grub_printf ("DER encoding differs in %u! (size: %u, expected: %u)\n", i, der_len, tv[i].der_len);
 	  return 1;
 	}
 
@@ -109,16 +106,13 @@ test_strings (void)
 				&str_len);
       if (ret != ASN1_SUCCESS)
 	{
-	  fprintf (stderr, "Decoding error in %u: %s\n", i,
-		   asn1_strerror (ret));
+	  grub_printf ("Decoding error in %u: %s\n", i, asn1_strerror (ret));
 	  return 1;
 	}
 
       if (str_len != tv[i].str_len || memcmp (str, tv[i].str, str_len) != 0)
 	{
-	  fprintf (stderr,
-		   "DER decoded data differ in %u! (size: %u, expected: %u)\n",
-		   i, der_len, tv[i].str_len);
+	  grub_printf ("DER decoded data differ in %u! (size: %u, expected: %u)\n", i, der_len, tv[i].str_len);
 	  return 1;
 	}
     }
@@ -132,16 +126,13 @@ test_strings (void)
 				&str_len, NULL);
       if (ret != ASN1_SUCCESS)
 	{
-	  fprintf (stderr, "BER decoding error in %u: %s\n", i,
-		   asn1_strerror (ret));
+	  grub_printf ("BER decoding error in %u: %s\n", i, asn1_strerror (ret));
 	  return 1;
 	}
 
       if (str_len != ber[i].str_len || memcmp (b, ber[i].str, str_len) != 0)
 	{
-	  fprintf (stderr,
-		   "BER decoded data differ in %u! (size: %u, expected: %u)\n",
-		   i, str_len, ber[i].str_len);
+	  grub_printf ("BER decoded data differ in %u! (size: %u, expected: %u)\n", i, str_len, ber[i].str_len);
 	  return 1;
 	}
       free (b);
diff --git a/grub-core/tests/asn1/tests/object-id-decoding.c b/grub-core/tests/asn1/tests/object-id-decoding.c
index fdbb8ea21..c087b46e3 100644
--- a/grub-core/tests/asn1/tests/object-id-decoding.c
+++ b/grub-core/tests/asn1/tests/object-id-decoding.c
@@ -85,10 +85,8 @@ test_object_id_decoding (void)
 				sizeof (str));
       if (ret != tv[i].expected_error)
 	{
-	  fprintf (stderr,
-		   "%d: asn1_get_object_id_der iter %lu: got '%s' expected %d\n",
-		   __LINE__, (unsigned long) i, asn1_strerror (ret),
-		   tv[i].expected_error);
+	  grub_printf ("%d: asn1_get_object_id_der iter %lu: got '%s' expected %d\n",
+		       __LINE__, (unsigned long) i, asn1_strerror (ret), tv[i].expected_error);
 	  return 1;
 	}
 
@@ -97,17 +95,15 @@ test_object_id_decoding (void)
 
       if (ret_len != tv[i].der_len - 1)
 	{
-	  fprintf (stderr,
-		   "%d: iter %lu: error in DER, length returned is %d, had %d\n",
-		   __LINE__, (unsigned long) i, ret_len, tv[i].der_len - 1);
+	  grub_printf ("%d: iter %lu: error in DER, length returned is %d, had %d\n",
+		       __LINE__, (unsigned long) i, ret_len, tv[i].der_len - 1);
 	  return 1;
 	}
 
       if (strcmp (tv[i].oid, str) != 0)
 	{
-	  fprintf (stderr,
-		   "%d: strcmp iter %lu: got invalid OID: %s, expected: %s\n",
-		   __LINE__, (unsigned long) i, str, tv[i].oid);
+	  grub_printf ("%d: strcmp iter %lu: got invalid OID: %s, expected: %s\n",
+		       __LINE__, (unsigned long) i, str, tv[i].oid);
 	  return 1;
 	}
 
diff --git a/grub-core/tests/asn1/tests/object-id-encoding.c b/grub-core/tests/asn1/tests/object-id-encoding.c
index a497015e3..e3da092cc 100644
--- a/grub-core/tests/asn1/tests/object-id-encoding.c
+++ b/grub-core/tests/asn1/tests/object-id-encoding.c
@@ -93,33 +93,29 @@ test_object_id_encoding (void)
 	{
 	  if (ret == tv[i].expected_error)
 	    continue;
-	  fprintf (stderr,
-		   "%d: iter %lu, encoding of OID failed: %s\n",
-		   __LINE__, (unsigned long) i, asn1_strerror (ret));
+	  grub_printf ("%d: iter %lu, encoding of OID failed: %s\n",
+		       __LINE__, (unsigned long) i, asn1_strerror (ret));
 	  return 1;
 	}
       else if (ret != tv[i].expected_error)
 	{
-	  fprintf (stderr,
-		   "%d: iter %lu, encoding of OID %s succeeded when expecting failure\n",
-		   __LINE__, (unsigned long) i, tv[i].oid);
+	  grub_printf ("%d: iter %lu, encoding of OID %s succeeded when expecting failure\n",
+		       __LINE__, (unsigned long) i, tv[i].oid);
 	  return 1;
 	}
 
       if (der_len != tv[i].der_len || memcmp (der, tv[i].der, der_len) != 0)
 	{
-	  fprintf (stderr,
-		   "%d: iter %lu, re-encoding of OID %s resulted to different string (%d vs %d bytes)\n",
-		   __LINE__, (unsigned long) i, tv[i].oid, der_len,
-		   tv[i].der_len);
-	  fprintf (stderr, "\nGot:\t\t");
+	  grub_printf ("%d: iter %lu, re-encoding of OID %s resulted to different string (%d vs %d bytes)\n",
+		   __LINE__, (unsigned long) i, tv[i].oid, der_len, tv[i].der_len);
+	  grub_printf ("\nGot:\t\t");
 	  for (j = 0; j < der_len; j++)
-	    fprintf (stderr, "%.2x", der[j]);
+	    grub_printf ("%.2x", der[j]);
 
-	  fprintf (stderr, "\nExpected:\t");
+	  grub_printf ("\nExpected:\t");
 	  for (j = 0; j < tv[i].der_len; j++)
-	    fprintf (stderr, "%.2x", tv[i].der[j]);
-	  fprintf (stderr, "\n");
+	    grub_printf ("%.2x", tv[i].der[j]);
+	  grub_printf ("\n");
 
 	  return 1;
 	}
diff --git a/grub-core/tests/asn1/tests/octet-string.c b/grub-core/tests/asn1/tests/octet-string.c
index 8c49c6e0c..d3a35dff8 100644
--- a/grub-core/tests/asn1/tests/octet-string.c
+++ b/grub-core/tests/asn1/tests/octet-string.c
@@ -131,9 +131,8 @@ test_octet_string (void)
 				sizeof (str), &str_size);
 	  if (ret != tv[i].expected_error)
 	    {
-	      fprintf (stderr,
-		       "%d: asn1_get_octet_der: %s: got %d expected %d\n",
-		       __LINE__, tv[i].name, ret, tv[i].expected_error);
+	      grub_printf ("%d: asn1_get_octet_der: %s: got %d expected %d\n",
+			   __LINE__, tv[i].name, ret, tv[i].expected_error);
 	      return 1;
 	    }
 	  if (tv[i].expected_error)
@@ -141,27 +140,25 @@ test_octet_string (void)
 
 	  if (ret_len != tv[i].der_len - 1)
 	    {
-	      fprintf (stderr,
-		       "%d: error in DER, length returned is %d, had %d\n",
-		       __LINE__, ret_len, tv[i].der_len - 1);
+	      grub_printf ("%d: error in DER, length returned is %d, had %d\n",
+			   __LINE__, ret_len, tv[i].der_len - 1);
 	      return 1;
 	    }
 
 	  if (str_size != tv[i].len
 	      || memcmp (tv[i].string, str, tv[i].len) != 0)
 	    {
-	      fprintf (stderr,
-		       "%d: memcmp: %s: got invalid decoding\n",
-		       __LINE__, tv[i].name);
+	      grub_printf ("%d: memcmp: %s: got invalid decoding\n",
+			   __LINE__, tv[i].name);
 
-	      fprintf (stderr, "\nGot:\t\t");
+	      grub_printf ("\nGot:\t\t");
 	      for (j = 0; j < str_size; j++)
-		fprintf (stderr, "%.2x", str[j]);
+		grub_printf ("%.2x", str[j]);
 
-	      fprintf (stderr, "\nExpected:\t");
+	      grub_printf ("\nExpected:\t");
 	      for (j = 0; j < tv[i].len; j++)
-		fprintf (stderr, "%.2x", tv[i].string[j]);
-	      fprintf (stderr, "\n");
+		grub_printf ("%.2x", tv[i].string[j]);
+	      grub_printf ("\n");
 	      return 1;
 	    }
 
@@ -172,8 +169,7 @@ test_octet_string (void)
 	  if (der_len != tv[i].der_len - 1
 	      || memcmp (tv[i].der_str + 1, der, tv[i].der_len - 1) != 0)
 	    {
-	      fprintf (stderr,
-		       "encoding: %s: got invalid encoding\n", tv[i].name);
+	      grub_printf ("encoding: %s: got invalid encoding\n", tv[i].name);
 	      return 1;
 	    }
 	}
@@ -185,10 +181,9 @@ test_octet_string (void)
 				(unsigned int *) &der_len);
       if (ret != tv[i].expected_error)
 	{
-	  fprintf (stderr,
-		   "%d: asn1_decode_simple_ber: %s: got %s expected %s\n",
-		   __LINE__, tv[i].name, asn1_strerror (ret),
-		   asn1_strerror (tv[i].expected_error));
+	  grub_printf ("%d: asn1_decode_simple_ber: %s: got %s expected %s\n",
+		       __LINE__, tv[i].name, asn1_strerror (ret),
+		       asn1_strerror (tv[i].expected_error));
 	  return 1;
 	}
       if (tv[i].expected_error)
@@ -196,25 +191,22 @@ test_octet_string (void)
 
       if (der_len != tv[i].der_len)
 	{
-	  fprintf (stderr,
-		   "%d: error: %s: DER, length returned is %d, had %d\n",
-		   __LINE__, tv[i].name, der_len, tv[i].der_len);
+	  grub_printf ("%d: error: %s: DER, length returned is %d, had %d\n",
+		       __LINE__, tv[i].name, der_len, tv[i].der_len);
 	  return 1;
 	}
 
       if (str_size != tv[i].len || memcmp (tv[i].string, tmp, tv[i].len) != 0)
 	{
-	  fprintf (stderr,
-		   "%d: memcmp: %s: got invalid decoding\n",
-		   __LINE__, tv[i].name);
-	  fprintf (stderr, "\nGot:\t\t");
+	  grub_printf ("%d: memcmp: %s: got invalid decoding\n", __LINE__, tv[i].name);
+	  grub_printf ("\nGot:\t\t");
 	  for (j = 0; j < str_size; j++)
-	    fprintf (stderr, "%.2x", tmp[j]);
+	    grub_printf ("%.2x", tmp[j]);
 
-	  fprintf (stderr, "\nExpected:\t");
+	  grub_printf ("\nExpected:\t");
 	  for (j = 0; j < tv[i].len; j++)
-	    fprintf (stderr, "%.2x", tv[i].string[j]);
-	  fprintf (stderr, "\n");
+	    grub_printf ("%.2x", tv[i].string[j]);
+	  grub_printf ("\n");
 	  return 1;
 	}
       free (tmp);
diff --git a/grub-core/tests/asn1/tests/reproducers.c b/grub-core/tests/asn1/tests/reproducers.c
index fa3cea762..0e3c9fd65 100644
--- a/grub-core/tests/asn1/tests/reproducers.c
+++ b/grub-core/tests/asn1/tests/reproducers.c
@@ -58,8 +58,7 @@ test_reproducers (void)
   result = asn1_array2tree (endless_asn1_tab, &definitions, errorDescription);
   if (result != ASN1_SUCCESS)
     {
-      asn1_perror (result);
-      printf ("ErrorDescription = %s\n\n", errorDescription);
+      grub_printf ("Error: %s\nErrorDescription = %s\n\n", asn1_strerror (result), errorDescription);
       return 1;
     }
 
@@ -69,8 +68,7 @@ test_reproducers (void)
   result = asn1_array2tree (tab, &definitions, errorDescription);
   if (result != ASN1_SUCCESS)
     {
-      asn1_perror (result);
-      printf ("ErrorDescription = %s\n\n", errorDescription);
+      grub_printf ("Error: %s\nErrorDescription = %s\n\n", asn1_strerror (result), errorDescription);
       return 1;
     }
 
-- 
2.43.0