From ef2e8b4914feea9b717f71dd381bf1ff09b493ea Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Thu, 15 Feb 2018 20:35:56 -0500 Subject: [PATCH 2/2] Be stricter about hashtable_from_mapping Signed-off-by: Stephen Gallagher --- 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