[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v21 15/33] asn1_test: enable the testcase only when GRUB_LONG_MAX
From: |
Gary Lin |
Subject: |
[PATCH v21 15/33] asn1_test: enable the testcase only when GRUB_LONG_MAX is larger than GRUB_INT_MAX |
Date: |
Mon, 4 Nov 2024 15:31:48 +0800 |
There is a testcase to test the values larger than 'int' but smaller
than 'long'. However, for some architectures, 'long' and 'int' are the
same, and the compiler may issue a warning like this:
grub-core/tests/asn1/tests/Test_overflow.c:48:50: error: left shift of negative
value [-Werror=shift-negative-value]
unsigned long num = ((long) GRUB_UINT_MAX) << 2;
^~
To avoid unnecessary error the testcase is enabled only when
GRUB_LONG_MAX is larger than GRUB_INT_MAX.
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
...-the-testcase-only-when-GRUB_LONG_MA.patch | 48 +++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644
grub-core/lib/libtasn1-patches/0013-asn1_test-enable-the-testcase-only-when-GRUB_LONG_MA.patch
diff --git
a/grub-core/lib/libtasn1-patches/0013-asn1_test-enable-the-testcase-only-when-GRUB_LONG_MA.patch
b/grub-core/lib/libtasn1-patches/0013-asn1_test-enable-the-testcase-only-when-GRUB_LONG_MA.patch
new file mode 100644
index 000000000..a81a350c9
--- /dev/null
+++
b/grub-core/lib/libtasn1-patches/0013-asn1_test-enable-the-testcase-only-when-GRUB_LONG_MA.patch
@@ -0,0 +1,48 @@
+From 6d308d9053447dcc003a9ca740c47c00932d3569 Mon Sep 17 00:00:00 2001
+From: Gary Lin <glin@suse.com>
+Date: Mon, 7 Oct 2024 11:33:19 +0800
+Subject: [PATCH 13/13] asn1_test: enable the testcase only when GRUB_LONG_MAX
+ is larger than GRUB_INT_MAX
+
+There is a testcase to test the values larger than 'int' but smaller
+than 'long'. However, for some architectures, 'long' and 'int' are the
+same, and the compiler may issue a warning like this:
+
+grub-core/tests/asn1/tests/Test_overflow.c:48:50: error: left shift of
negative value [-Werror=shift-negative-value]
+ unsigned long num = ((long) GRUB_UINT_MAX) << 2;
+ ^~
+
+To avoid unnecessary error the testcase is enabled only when
+GRUB_LONG_MAX is larger than GRUB_INT_MAX.
+
+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/Test_overflow.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/grub-core/tests/asn1/tests/Test_overflow.c
b/grub-core/tests/asn1/tests/Test_overflow.c
+index 65843abf6..fdeff5634 100644
+--- a/grub-core/tests/asn1/tests/Test_overflow.c
++++ b/grub-core/tests/asn1/tests/Test_overflow.c
+@@ -43,7 +43,7 @@ test_overflow (void)
+
+ /* Test that values larger than int but smaller than long are
+ rejected. This limitation was introduced with libtasn1 2.12. */
+- if (GRUB_LONG_MAX > GRUB_INT_MAX)
++#if (GRUB_LONG_MAX > GRUB_INT_MAX)
+ {
+ unsigned long num = ((long) GRUB_UINT_MAX) << 2;
+ unsigned char der[20];
+@@ -61,6 +61,7 @@ test_overflow (void)
+ return 1;
+ }
+ }
++#endif
+
+ /* Test that values larger than would fit in the input string are
+ rejected. This problem was fixed in libtasn1 2.12. */
+--
+2.43.0
+
--
2.43.0
- [PATCH v21 00/33] Automatic Disk Unlock with TPM2, Gary Lin, 2024/11/04
- [PATCH v21 01/33] posix_wrap: tweaks in preparation for libtasn1, Gary Lin, 2024/11/04
- [PATCH v21 03/33] libtasn1: disable code not needed in grub, Gary Lin, 2024/11/04
- [PATCH v21 04/33] libtasn1: replace strcat() with strcpy() in _asn1_str_cat(), Gary Lin, 2024/11/04
- [PATCH v21 02/33] libtasn1: import libtasn1-4.19.0, Gary Lin, 2024/11/04
- [PATCH v21 05/33] libtasn1: replace strcat() with _asn1_str_cat(), Gary Lin, 2024/11/04
- [PATCH v21 08/33] libtasn1: fix the potential buffer overrun, Gary Lin, 2024/11/04
- [PATCH v21 09/33] asn1_test: include asn1_test.h only, Gary Lin, 2024/11/04
- [PATCH v21 07/33] libtasn1: Use grub_divmod64() for division, Gary Lin, 2024/11/04
- [PATCH v21 15/33] asn1_test: enable the testcase only when GRUB_LONG_MAX is larger than GRUB_INT_MAX,
Gary Lin <=
- [PATCH v21 16/33] libtasn1: compile into asn1 module, Gary Lin, 2024/11/04
- [PATCH v21 14/33] asn1_test: use the grub-specific functions and types, Gary Lin, 2024/11/04
- [PATCH v21 06/33] libtasn1: adjust the header paths in libtasn1.h, Gary Lin, 2024/11/04
- [PATCH v21 13/33] asn1_test: print the error messages with grub_printf(), Gary Lin, 2024/11/04
- [PATCH v21 11/33] asn1_test: return either 0 or 1 to reflect the results, Gary Lin, 2024/11/04
- [PATCH v21 10/33] asn1_test: rename the main functions to the test names, Gary Lin, 2024/11/04
- [PATCH v21 12/33] asn1_test: remove 'verbose' and the unnecessary printf(), Gary Lin, 2024/11/04
- [PATCH v21 17/33] asn1_test: test module for libtasn1, Gary Lin, 2024/11/04
- [PATCH v21 20/33] tss2: Add TPM2 buffer handling functions, Gary Lin, 2024/11/04
- [PATCH v21 18/33] libtasn1: Add the documentation, Gary Lin, 2024/11/04