From 3dc97759fd842d7d766df593c19ea3d76d98f0c0 Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Tue, 8 Nov 2022 01:46:50 -0500 Subject: [PATCH] scanner: Fail on invalid attribute names These should be caught by the DTD check, but failed DTD validation is non-fatal by default. Signed-off-by: Demi Marie Obenour --- src/scanner.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index 6ac67243..19f566d4 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -742,29 +742,30 @@ start_element(void *data, const char *element_name, const char **atts) for (i = 0; atts[i]; i += 2) { if (strcmp(atts[i], "name") == 0) name = atts[i + 1]; - if (strcmp(atts[i], "version") == 0) { + else if (strcmp(atts[i], "version") == 0) { version = strtouint(atts[i + 1]); if (version == -1) fail(&ctx->loc, "wrong version (%s)", atts[i + 1]); - } - if (strcmp(atts[i], "type") == 0) + } else if (strcmp(atts[i], "type") == 0) type = atts[i + 1]; - if (strcmp(atts[i], "value") == 0) + else if (strcmp(atts[i], "value") == 0) value = atts[i + 1]; - if (strcmp(atts[i], "interface") == 0) + else if (strcmp(atts[i], "interface") == 0) interface_name = atts[i + 1]; - if (strcmp(atts[i], "summary") == 0) + else if (strcmp(atts[i], "summary") == 0) summary = atts[i + 1]; - if (strcmp(atts[i], "since") == 0) + else if (strcmp(atts[i], "since") == 0) since = atts[i + 1]; - if (strcmp(atts[i], "deprecated-since") == 0) + else if (strcmp(atts[i], "deprecated-since") == 0) deprecated_since = atts[i + 1]; - if (strcmp(atts[i], "allow-null") == 0) + else if (strcmp(atts[i], "allow-null") == 0) allow_null = atts[i + 1]; - if (strcmp(atts[i], "enum") == 0) + else if (strcmp(atts[i], "enum") == 0) enumeration_name = atts[i + 1]; - if (strcmp(atts[i], "bitfield") == 0) + else if (strcmp(atts[i], "bitfield") == 0) bitfield = atts[i + 1]; + else + fail(&ctx->loc, "invalid attribute name (%s)", atts[i]); } ctx->character_data_length = 0;