libmodulemd/0001-Be-stricter-about-simpleset_from_sequence.patch
2018-02-15 20:37:35 -05:00

55 lines
1.7 KiB
Diff

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