On Fri, Jun 14, 2024 at 02:45:40PM +0800, Gary Lin wrote:
> From: Daniel Axtens <d...@axtens.net>
>
> Import tests from libtasn1 that don't use functionality we don't
> import. This test module is integrated into functional_test so that the
> user can run the test in grub shell.
>
> This doesn't test the full decoder but that will be exercised in
> test suites for coming patch sets.
>
> Add testcase target in accordance with
> 5e10be48e5 tests: Add check-native and check-nonnative make targets
>
> Cc: Vladimir Serbinenko <phco...@gmail.com>
> Signed-off-by: Daniel Axtens <d...@axtens.net>
> Signed-off-by: Gary Lin <g...@suse.com>
> ---
>  Makefile.util.def                             |   6 +
>  grub-core/Makefile.core.def                   |  14 ++
>  .../tests/asn1/CVE-2018-1000654-1_asn1_tab.h  |  32 +++
>  .../tests/asn1/CVE-2018-1000654-2_asn1_tab.h  |  36 +++
>  grub-core/tests/asn1/CVE-2018-1000654.c       |  58 +++++
>  grub-core/tests/asn1/Test_overflow.c          | 134 ++++++++++++
>  grub-core/tests/asn1/Test_simple.c            | 205 ++++++++++++++++++
>  grub-core/tests/asn1/Test_strings.c           | 142 ++++++++++++
>  grub-core/tests/asn1/asn1_test.c              |  49 +++++
>  grub-core/tests/asn1/asn1_test.h              |  44 ++++
>  grub-core/tests/asn1/object-id-decoding.c     | 109 ++++++++++
>  grub-core/tests/asn1/object-id-encoding.c     | 114 ++++++++++
>  grub-core/tests/asn1/octet-string.c           | 199 +++++++++++++++++
>  grub-core/tests/asn1/reproducers.c            |  80 +++++++
>  grub-core/tests/lib/functional_test.c         |   1 +
>  tests/asn1_test.in                            |  11 +

If most of these files come from libtasn1 then you should add a list of
commands which allows us recreate them from libtasn1 source. And probably
introduction of original libtasn1 test files should happen in the patch #2.

[...]

> diff --git a/grub-core/tests/asn1/Test_overflow.c 
> b/grub-core/tests/asn1/Test_overflow.c
> new file mode 100644
> index 000000000..aff6b410a
> --- /dev/null
> +++ b/grub-core/tests/asn1/Test_overflow.c
> @@ -0,0 +1,134 @@
> +/*
> + * Copyright (C) 2012-2014 Free Software Foundation, Inc.
> + *
> + * This file is part of LIBTASN1.
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + *
> + */
> +
> +/* Written by Simon Josefsson */
> +
> +#include "asn1_test.h"
> +
> +int
> +test_overflow(void)
> +{
> +  /* Test that values larger than long are rejected.  This has worked
> +     fine with all versions of libtasn1. */
> +
> +  {
> +    unsigned char der[] = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
> +    long l;
> +    int len;
> +
> +    l = asn1_get_length_der (der, sizeof der, &len);
> +
> +    if (l != -2L)
> +      {
> +     grub_printf ("ERROR: asn1_get_length_der bignum (l %ld len %d)\n", l, 
> len);
> +     return 1;
> +      }
> +  }
> +
> +  /* 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)

This change suggests it is a mixture of libtasn1 source and GRUB specific
patches. Please disaggregate them.

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to