Code

frontend/analyzer: Check name parameters for FETCH.
authorSebastian Harl <sh@tokkee.org>
Tue, 4 Nov 2014 07:34:28 +0000 (08:34 +0100)
committerSebastian Harl <sh@tokkee.org>
Tue, 4 Nov 2014 07:34:28 +0000 (08:34 +0100)
src/frontend/analyzer.c

index 8c6b74de6a0ea74d177b5a43efe2e6eee32d299d..93debf5e4530d800a0ad2dc020c6256934f2c6fd 100644 (file)
@@ -144,9 +144,13 @@ sdb_fe_analyze(sdb_conn_node_t *node)
        /* For now, this function checks basic matcher attributes only;
         * later, this may be turned into one of multiple AST visitors. */
        if (node->cmd == CONNECTION_FETCH) {
-               if (CONN_FETCH(node)->filter)
-                       filter = CONN_FETCH(node)->filter->matcher;
-               context = CONN_FETCH(node)->type;
+               conn_fetch_t *fetch = CONN_FETCH(node);
+               if (((fetch->type == SDB_HOST) && fetch->name)
+                               || ((fetch->type != SDB_HOST) && (! fetch->name)))
+                       return -1;
+               if (fetch->filter)
+                       filter = fetch->filter->matcher;
+               context = fetch->type;
        }
        else if (node->cmd == CONNECTION_LIST) {
                if (CONN_LIST(node)->filter)