aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-29 19:11:47 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-29 19:11:51 +0100
commite7bcf3d8a0c83cc7bc3970087beab47a7c7a14bd (patch)
tree87d0e7d4a142224717fe528bd6ce6f76205a95f6
parentsome test files (diff)
downloadmds-e7bcf3d8a0c83cc7bc3970087beab47a7c7a14bd.tar.gz
mds-e7bcf3d8a0c83cc7bc3970087beab47a7c7a14bd.tar.bz2
mds-e7bcf3d8a0c83cc7bc3970087beab47a7c7a14bd.tar.xz
mds-kbdc: check that there is something after the :
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/mds-kbdc/make-tree.c11
-rw-r--r--test-files/mds-kbdc/make-tree/invalid/truncated_mapping2
2 files changed, 11 insertions, 2 deletions
diff --git a/src/mds-kbdc/make-tree.c b/src/mds-kbdc/make-tree.c
index 26ee0a7..cdfae40 100644
--- a/src/mds-kbdc/make-tree.c
+++ b/src/mds-kbdc/make-tree.c
@@ -901,6 +901,7 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_parsed_t* restrict res
else if (strchr("\\\"<([0123456789", *line))
{
size_t stack_orig = stack_ptr + 1;
+ char* colon;
#define node supernode
#define inner sequence
NEW_NODE(map, MAP);
@@ -915,10 +916,10 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_parsed_t* restrict res
stack_ptr--;
*end = prev_end_char;
SKIP_SPACES(line);
- if (*line++ != ':')
+ if (colon = line, *line++ != ':')
{
LEAF;
- continue; /* Not an error in macros. */
+ continue; /* Not an error in functions. */
}
BRANCH(":");
#undef inner
@@ -931,6 +932,12 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_parsed_t* restrict res
#define node supernode
LEAF;
#undef node
+ if (supernode->result == NULL)
+ {
+ NEW_ERROR(1, ERROR, "output missing");
+ error->start = (size_t)(colon - LINE);
+ error->end = error->start + 1;
+ }
if (*line == '\0')
continue;
end = line + strlen(line), prev_end_char = *end;
diff --git a/test-files/mds-kbdc/make-tree/invalid/truncated_mapping b/test-files/mds-kbdc/make-tree/invalid/truncated_mapping
new file mode 100644
index 0000000..b3a89a7
--- /dev/null
+++ b/test-files/mds-kbdc/make-tree/invalid/truncated_mapping
@@ -0,0 +1,2 @@
+<my_key> :
+