|
|
1638d2 |
From b0dd663edd6ab66ec26c48ff34a52afa040694e6 Mon Sep 17 00:00:00 2001
|
|
|
1638d2 |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
1638d2 |
Date: Thu, 22 Jul 2021 15:23:55 +0200
|
|
|
1638d2 |
Subject: [PATCH] Accept 18446744073709551615 buildorder if
|
|
|
1638d2 |
accept_overflowed_buildorder build boolean is true
|
|
|
1638d2 |
MIME-Version: 1.0
|
|
|
1638d2 |
Content-Type: text/plain; charset=UTF-8
|
|
|
1638d2 |
Content-Transfer-Encoding: 8bit
|
|
|
1638d2 |
|
|
|
1638d2 |
7c0158bcec05b692d27e37ff46a134f4e294d957 commit (Reject invalid signed
|
|
|
1638d2 |
integers (rpm buildorder), as found in 2.13.0 release, fortified
|
|
|
1638d2 |
parsing signed integers.
|
|
|
1638d2 |
|
|
|
1638d2 |
It turned out that RHEL 8 delivers a few modules:
|
|
|
1638d2 |
|
|
|
1638d2 |
container-tools:rhel8:8020120200601155013:ffd2803a
|
|
|
1638d2 |
container-tools:rhel8:8030020200923153805:2a301c24
|
|
|
1638d2 |
container-tools:rhel8:8030020201124131330:830d479e
|
|
|
1638d2 |
container-tools:rhel8:8030120210208205200:c127ee91
|
|
|
1638d2 |
|
|
|
1638d2 |
which contain an invalid buildorder value 18446744073709551615. DNF
|
|
|
1638d2 |
then warned on loading them into an index and ignored them:
|
|
|
1638d2 |
|
|
|
1638d2 |
# dnf module list --repoid pulp-appstream
|
|
|
1638d2 |
Last metadata expiration check: 3:59:10 ago on Wed 21 Jul 2021 12:38:00 PM CEST.
|
|
|
1638d2 |
Module yaml error: Failed to parse buildorder in component: 18446744073709551615: The integer value is larger than 9223372036854775807 [line 118 col 9]
|
|
|
1638d2 |
Module yaml error: Failed to parse buildorder in component: 18446744073709551615: The integer value is larger than 9223372036854775807 [line 118 col 9]
|
|
|
1638d2 |
Module yaml error: Failed to parse buildorder in component: 18446744073709551615: The integer value is larger than 9223372036854775807 [line 107 col 9]
|
|
|
1638d2 |
Module yaml error: Failed to parse buildorder in component: 18446744073709551615: The integer value is larger than 9223372036854775807 [line 114 col 9]
|
|
|
1638d2 |
Module yaml error: Failed to parse buildorder in component: 18446744073709551615: The integer value is larger than 9223372036854775807 [line 118 col 9]
|
|
|
1638d2 |
Module yaml error: Failed to parse buildorder in component: 18446744073709551615: The integer value is larger than 9223372036854775807 [line 118 col 9]
|
|
|
1638d2 |
Module yaml error: Failed to parse buildorder in component: 18446744073709551615: The integer value is larger than 9223372036854775807 [line 107 col 9]
|
|
|
1638d2 |
Module yaml error: Failed to parse buildorder in component: 18446744073709551615: The integer value is larger than 9223372036854775807 [line 114 col 9]
|
|
|
1638d2 |
|
|
|
1638d2 |
Those were probably built with a broken MBS/libmodulemd which
|
|
|
1638d2 |
loaded -1 and serialized it as an 64-bit unsigned integer
|
|
|
1638d2 |
18446744073709551615.
|
|
|
1638d2 |
|
|
|
1638d2 |
Because the distributor does not change once-released builds, it
|
|
|
1638d2 |
became impossible to process them with libmodulemd-2.13.0.
|
|
|
1638d2 |
|
|
|
1638d2 |
This patch adds an accept_overflowed_buildorder build option (disabled
|
|
|
1638d2 |
by default) which enables a workaround to accept 18446744073709551615
|
|
|
1638d2 |
string as -1 integer when parsing 64-bit signed integers. (The type is
|
|
|
1638d2 |
used only in buildorder field now).
|
|
|
1638d2 |
|
|
|
1638d2 |
(Originally, I developed a more complicated patch only affecting
|
|
|
1638d2 |
loading while keeping validation strict. But that was not enough for
|
|
|
1638d2 |
DNF, creareterepo_c and probably many other tools. Thus I prepared
|
|
|
1638d2 |
even more complicated patch affecting both loading and validation of
|
|
|
1638d2 |
modulemd formats only (cf. modulemd-packager-v3) and that helped DNF.
|
|
|
1638d2 |
But the patch ugglified to code to much and considering it's only
|
|
|
1638d2 |
a temporary hack, I decided for this simple patch which affects
|
|
|
1638d2 |
loading and validation of all formats.)
|
|
|
1638d2 |
|
|
|
1638d2 |
Petr Písař: Ported to 2.13.0 from
|
|
|
1638d2 |
37a688cc12d7fbab67fda95c47a4605405d7a154.
|
|
|
1638d2 |
|
|
|
1638d2 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
1638d2 |
---
|
|
|
1638d2 |
meson.build | 1 +
|
|
|
1638d2 |
meson_options.txt | 3 +++
|
|
|
1638d2 |
modulemd/meson.build | 2 ++
|
|
|
1638d2 |
modulemd/modulemd-yaml-util.c | 11 +++++++++++
|
|
|
1638d2 |
modulemd/tests/test-modulemd-parse_int64.c | 15 ++++++++++++++-
|
|
|
1638d2 |
5 files changed, 31 insertions(+), 1 deletion(-)
|
|
|
1638d2 |
|
|
|
1638d2 |
diff --git a/meson.build b/meson.build
|
|
|
1638d2 |
index 37792b3..bbb56ba 100644
|
|
|
1638d2 |
--- a/meson.build
|
|
|
1638d2 |
+++ b/meson.build
|
|
|
1638d2 |
@@ -215,6 +215,7 @@ if meson.version().version_compare('>=0.53')
|
|
|
1638d2 |
'Python 2 Support': get_option('with_py2'),
|
|
|
1638d2 |
'Python 3 Support': get_option('with_py3'),
|
|
|
1638d2 |
'Skip Introspection': get_option('skip_introspection'),
|
|
|
1638d2 |
+ 'Accept overflowed buildorder': get_option('accept_overflowed_buildorder'),
|
|
|
1638d2 |
'Test Installed Library': get_option('test_installed_lib'),
|
|
|
1638d2 |
}, section: 'Build Configuration')
|
|
|
1638d2 |
endif
|
|
|
1638d2 |
diff --git a/meson_options.txt b/meson_options.txt
|
|
|
1638d2 |
index 7873d42..3d84459 100644
|
|
|
1638d2 |
--- a/meson_options.txt
|
|
|
1638d2 |
+++ b/meson_options.txt
|
|
|
1638d2 |
@@ -11,6 +11,9 @@
|
|
|
1638d2 |
#
|
|
|
1638d2 |
# REMEMBER TO UPDATE THE SUMMARY() IN meson.build when adding options here
|
|
|
1638d2 |
|
|
|
1638d2 |
+option('accept_overflowed_buildorder', type : 'boolean', value: 'false',
|
|
|
1638d2 |
+ description : 'Accept overflowed 18446744073709551615 buildorder as -1. This breaks a specification, but some RHEL 8 module builds look like that.')
|
|
|
1638d2 |
+
|
|
|
1638d2 |
option('verbose_tests', type : 'boolean', value : true,
|
|
|
1638d2 |
description : 'Tests that are run under the "debug" configuration will print all debug messages. Disable this option for valgrind checks, as it speeds it up substantially.')
|
|
|
1638d2 |
|
|
|
1638d2 |
diff --git a/modulemd/meson.build b/modulemd/meson.build
|
|
|
1638d2 |
index 2a60364..0b74818 100644
|
|
|
1638d2 |
--- a/modulemd/meson.build
|
|
|
1638d2 |
+++ b/modulemd/meson.build
|
|
|
1638d2 |
@@ -14,6 +14,7 @@
|
|
|
1638d2 |
test_installed_lib = get_option('test_installed_lib')
|
|
|
1638d2 |
skip_introspection = get_option('skip_introspection')
|
|
|
1638d2 |
verbose_tests = get_option('verbose_tests')
|
|
|
1638d2 |
+accept_overflowed_buildorder = get_option('accept_overflowed_buildorder')
|
|
|
1638d2 |
clang_simple_version_script = find_program ('clang_simple_version.sh')
|
|
|
1638d2 |
|
|
|
1638d2 |
|
|
|
1638d2 |
@@ -144,6 +145,7 @@ cdata.set('HAVE_RPMIO', rpm.found())
|
|
|
1638d2 |
cdata.set('HAVE_LIBMAGIC', magic.found())
|
|
|
1638d2 |
cdata.set('HAVE_GDATE_AUTOPTR', has_gdate_autoptr)
|
|
|
1638d2 |
cdata.set('HAVE_EXTEND_AND_STEAL', has_extend_and_steal)
|
|
|
1638d2 |
+cdata.set('HAVE_OVERFLOWED_BUILDORDER', accept_overflowed_buildorder)
|
|
|
1638d2 |
configure_file(
|
|
|
1638d2 |
output : 'config.h',
|
|
|
1638d2 |
configuration : cdata
|
|
|
1638d2 |
diff --git a/modulemd/modulemd-yaml-util.c b/modulemd/modulemd-yaml-util.c
|
|
|
1638d2 |
index 6cbf4cc..ad0bd3c 100644
|
|
|
1638d2 |
--- a/modulemd/modulemd-yaml-util.c
|
|
|
1638d2 |
+++ b/modulemd/modulemd-yaml-util.c
|
|
|
1638d2 |
@@ -11,6 +11,7 @@
|
|
|
1638d2 |
* For more information on free software, see <https://www.gnu.org/philosophy/free-sw.en.html>.
|
|
|
1638d2 |
*/
|
|
|
1638d2 |
|
|
|
1638d2 |
+#include "config.h"
|
|
|
1638d2 |
#include "modulemd-errors.h"
|
|
|
1638d2 |
#include "private/modulemd-subdocument-info-private.h"
|
|
|
1638d2 |
#include "private/modulemd-util.h"
|
|
|
1638d2 |
@@ -441,6 +442,16 @@ modulemd_yaml_parse_int64 (yaml_parser_t *parser, GError **error)
|
|
|
1638d2 |
|
|
|
1638d2 |
if ((value == G_MAXINT64 && errno == ERANGE))
|
|
|
1638d2 |
{
|
|
|
1638d2 |
+#ifdef HAVE_OVERFLOWED_BUILDORDER
|
|
|
1638d2 |
+ /* A temporary hack. Remove when RHEL 8 goes end of life. */
|
|
|
1638d2 |
+ if (g_str_equal ((const gchar *)event.data.scalar.value,
|
|
|
1638d2 |
+ "18446744073709551615"))
|
|
|
1638d2 |
+ {
|
|
|
1638d2 |
+ g_debug ("Coercing an invalid signed 64-bit integer to -1: %s",
|
|
|
1638d2 |
+ (const gchar *)event.data.scalar.value);
|
|
|
1638d2 |
+ return -1;
|
|
|
1638d2 |
+ }
|
|
|
1638d2 |
+#endif
|
|
|
1638d2 |
g_set_error (error,
|
|
|
1638d2 |
MODULEMD_YAML_ERROR,
|
|
|
1638d2 |
MODULEMD_ERROR_VALIDATE,
|
|
|
1638d2 |
diff --git a/modulemd/tests/test-modulemd-parse_int64.c b/modulemd/tests/test-modulemd-parse_int64.c
|
|
|
1638d2 |
index 2ccfb53..8759c21 100644
|
|
|
1638d2 |
--- a/modulemd/tests/test-modulemd-parse_int64.c
|
|
|
1638d2 |
+++ b/modulemd/tests/test-modulemd-parse_int64.c
|
|
|
1638d2 |
@@ -11,6 +11,7 @@
|
|
|
1638d2 |
* For more information on free software, see <https://www.gnu.org/philosophy/free-sw.en.html>.
|
|
|
1638d2 |
*/
|
|
|
1638d2 |
|
|
|
1638d2 |
+#include "config.h"
|
|
|
1638d2 |
#include <glib.h>
|
|
|
1638d2 |
#include <locale.h>
|
|
|
1638d2 |
#include <string.h>
|
|
|
1638d2 |
@@ -36,7 +37,7 @@ test (const char *input, gint64 expected_value, gboolean expected_error)
|
|
|
1638d2 |
g_assert_nonnull (error);
|
|
|
1638d2 |
else
|
|
|
1638d2 |
g_assert_null (error);
|
|
|
1638d2 |
- g_assert_cmpuint (parsed, ==, expected_value);
|
|
|
1638d2 |
+ g_assert_cmpint (parsed, ==, expected_value);
|
|
|
1638d2 |
}
|
|
|
1638d2 |
|
|
|
1638d2 |
static void
|
|
|
1638d2 |
@@ -69,6 +70,16 @@ test_int64_invalid_too_big (void)
|
|
|
1638d2 |
test ("9223372036854775808", 0, TRUE);
|
|
|
1638d2 |
}
|
|
|
1638d2 |
|
|
|
1638d2 |
+static void
|
|
|
1638d2 |
+test_int64_invalid_overflowed (void)
|
|
|
1638d2 |
+{
|
|
|
1638d2 |
+#ifdef HAVE_OVERFLOWED_BUILDORDER
|
|
|
1638d2 |
+ test ("18446744073709551615", -1, FALSE);
|
|
|
1638d2 |
+#else
|
|
|
1638d2 |
+ test ("18446744073709551615", 0, TRUE);
|
|
|
1638d2 |
+#endif
|
|
|
1638d2 |
+}
|
|
|
1638d2 |
+
|
|
|
1638d2 |
static void
|
|
|
1638d2 |
test_int64_invalid_too_small (void)
|
|
|
1638d2 |
{
|
|
|
1638d2 |
@@ -143,6 +154,8 @@ main (int argc, char *argv[])
|
|
|
1638d2 |
test_int64_invalid_too_big);
|
|
|
1638d2 |
g_test_add_func ("/modulemd/v2/int64/yaml/parse/invalid_too_small",
|
|
|
1638d2 |
test_int64_invalid_too_small);
|
|
|
1638d2 |
+ g_test_add_func ("/modulemd/v2/int64/yaml/parse/invalid_overflowed",
|
|
|
1638d2 |
+ test_int64_invalid_overflowed);
|
|
|
1638d2 |
|
|
|
1638d2 |
g_test_add_func ("/modulemd/v2/uint64/yaml/parse/valid", test_uint64_valid);
|
|
|
1638d2 |
g_test_add_func ("/modulemd/v2/uint64/yaml/parse/invalid_no_digit",
|
|
|
1638d2 |
--
|
|
|
1638d2 |
2.31.1
|
|
|
1638d2 |
|