Be more strict with certain parser edge-cases

- Replace popt argument processing with glib
- Drop upstreamed patches

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2018-02-16 11:41:26 -05:00
parent d0df9e74ca
commit fbfc57796a
No known key found for this signature in database
GPG Key ID: 7A25556236BAA3A3
5 changed files with 9 additions and 116 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
/modulemd-0.2.2.tar.xz
/modulemd-1.0.0.tar.xz
/modulemd-1.0.1.tar.xz
/modulemd-1.0.2.tar.xz

View File

@ -1,54 +0,0 @@
From e44cb185d1e6d18960c648b8233e4a71e458444f Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Thu, 15 Feb 2018 20:30:12 -0500
Subject: [PATCH] Be stricter about simpleset_from_sequence
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
---
modulemd/modulemd-yaml-parser.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/modulemd/modulemd-yaml-parser.c b/modulemd/modulemd-yaml-parser.c
index a1d2a3ed7ee0f89f4e0950710c79747743778d13..16daaddff1e1f82ba6761c39ba47819e5e2a281b 100644
--- a/modulemd/modulemd-yaml-parser.c
+++ b/modulemd/modulemd-yaml-parser.c
@@ -2257,10 +2257,11 @@ static gboolean
_simpleset_from_sequence (yaml_parser_t *parser,
ModulemdSimpleSet **_set,
GError **error)
{
yaml_event_t event;
+ gboolean started = FALSE;
gboolean done = FALSE;
ModulemdSimpleSet *set = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -2276,18 +2277,24 @@ _simpleset_from_sequence (yaml_parser_t *parser,
switch (event.type)
{
case YAML_SEQUENCE_START_EVENT:
/* Sequence has begun */
+ started = TRUE;
break;
case YAML_SEQUENCE_END_EVENT:
/* Sequence has concluded. Return */
done = TRUE;
break;
case YAML_SCALAR_EVENT:
+ if (!started)
+ {
+ MMD_YAML_ERROR_RETURN (
+ error, "Received scalar where sequence expected");
+ }
modulemd_simpleset_add (set, (const gchar *)event.data.scalar.value);
break;
default:
/* We received a YAML event we shouldn't expect at this level */
--
2.14.3

View File

@ -1,54 +0,0 @@
From ef2e8b4914feea9b717f71dd381bf1ff09b493ea Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Thu, 15 Feb 2018 20:35:56 -0500
Subject: [PATCH 2/2] Be stricter about hashtable_from_mapping
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
---
modulemd/modulemd-yaml-parser.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/modulemd/modulemd-yaml-parser.c b/modulemd/modulemd-yaml-parser.c
index 064135fc45b15df608b4bc636c64ca736bd789ef..ebdb63abb9b970834a8e8f8859345d9adc152d9a 100644
--- a/modulemd/modulemd-yaml-parser.c
+++ b/modulemd/modulemd-yaml-parser.c
@@ -2320,10 +2320,11 @@ static gboolean
_hashtable_from_mapping (yaml_parser_t *parser,
GHashTable **_htable,
GError **error)
{
yaml_event_t event;
+ gboolean started = FALSE;
gboolean done = FALSE;
GHashTable *htable = NULL;
gchar *name = NULL;
gchar *value = NULL;
@@ -2339,18 +2340,24 @@ _hashtable_from_mapping (yaml_parser_t *parser,
switch (event.type)
{
case YAML_MAPPING_START_EVENT:
/* The dictionary has begun */
+ started = TRUE;
break;
case YAML_MAPPING_END_EVENT:
/* We've processed the whole dictionary */
done = TRUE;
break;
case YAML_SCALAR_EVENT:
+ if (!started)
+ {
+ MMD_YAML_ERROR_RETURN (
+ error, "Received scalar where mapping expected");
+ }
name = g_strdup ((const gchar *)event.data.scalar.value);
YAML_PARSER_PARSE_WITH_ERROR_RETURN (
parser, &event, error, "Parser error");
if (event.type != YAML_SCALAR_EVENT)
{
--
2.14.3

View File

@ -1,11 +1,11 @@
%global majorversion 1
%global minorversion 0
%global patchversion 1
%global patchversion 2
%global majorminorversion %{majorversion}.%{minorversion}
Name: libmodulemd
Version: %{majorminorversion}%{?patchversion:.%{patchversion}}
Release: 2%{?dist}
Release: 1%{?dist}
Summary: Module metadata manipulation library
License: MIT
@ -18,14 +18,9 @@ BuildRequires: pkgconfig(gobject-2.0)
BuildRequires: pkgconfig(gobject-introspection-1.0)
BuildRequires: pkgconfig(yaml-0.1)
BuildRequires: pkgconfig(gtk-doc)
BuildRequires: pkgconfig(popt)
# Patches
# Upstream patches for proper sequence and mapping validation
Patch0001: 0001-Be-stricter-about-simpleset_from_sequence.patch
Patch0002: 0002-Be-stricter-about-hashtable_from_mapping.patch
%description
C Library for manipulating module metadata files.
See https://pagure.io/modulemd for more details.
@ -72,6 +67,11 @@ export LC_CTYPE=C.utf8
%{_datadir}/gtk-doc/html/modulemd/
%changelog
* Fri Feb 16 2018 Stephen Gallagher <sgallagh@redhat.com> - 1.0.2-1
- Be more strict with certain parser edge-cases
- Replace popt argument processing with glib
- Drop upstreamed patches
* Thu Feb 15 2018 Stephen Gallagher <sgallagh@redhat.com> - 1.0.1-2
- Handle certain unlikely format violations

View File

@ -1 +1 @@
SHA512 (modulemd-1.0.1.tar.xz) = b1b0c4e4bf75b4d7152ce76fc67189511a362a9c69a1ed708eed7004ed6dc4a31e2cc1bcd9364c38c58579d9176a567d6e870a4e3e6660b97e9108e9610c0cd3
SHA512 (modulemd-1.0.2.tar.xz) = bd384ea1a806c18cb01ed874e4b7fa545fa3dbade705420cb7512af1aa726fd6d1ec4860f4791efae49b100dde4281967d7c42134a3adea6f17315edc11020b7