diff --git a/query_classifier/query_classifier.cc b/query_classifier/query_classifier.cc index 874251d32..9667193ed 100644 --- a/query_classifier/query_classifier.cc +++ b/query_classifier/query_classifier.cc @@ -1572,7 +1572,7 @@ char* skygw_get_qtype_str( skygw_query_op_t query_classifier_get_operation(GWBUF* querybuf) { LEX* lex = get_lex(querybuf); - skygw_query_op_t operation; + skygw_query_op_t operation = QUERY_OP_UNDEFINED; if(lex){ switch(lex->sql_command){ case SQLCOM_SELECT: diff --git a/server/core/hashtable.c b/server/core/hashtable.c index 86d1d821e..df88ac9f7 100644 --- a/server/core/hashtable.c +++ b/server/core/hashtable.c @@ -678,12 +678,14 @@ void *key, *value; if (!(*keywrite)(fd, key)) { close(fd); + hashtable_iterator_free(iter); return -1; } if ((value = hashtable_fetch(table, key)) == NULL || (*valuewrite)(fd, value) == 0) { close(fd); + hashtable_iterator_free(iter); return -1; } rval++; @@ -691,10 +693,13 @@ void *key, *value; } /* Now go back and write the count of entries */ - lseek(fd, 7L, SEEK_SET); - write(fd, &rval, sizeof(rval)); - + if(lseek(fd, 7L, SEEK_SET) != -1) + { + write(fd, &rval, sizeof(rval)); + } + close(fd); + hashtable_iterator_free(iter); return rval; } diff --git a/server/modules/filter/fwfilter.c b/server/modules/filter/fwfilter.c index 31f286a9e..5cd8d5d78 100644 --- a/server/modules/filter/fwfilter.c +++ b/server/modules/filter/fwfilter.c @@ -639,7 +639,7 @@ void link_rules(char* rule, FW_INSTANCE* instance) bool match_any; char *tok, *ruleptr, *userptr, *modeptr; - char **saveptr; + char **saveptr = NULL; RULELIST* rulelist = NULL; userptr = strstr(rule,"users "); @@ -656,7 +656,7 @@ void link_rules(char* rule, FW_INSTANCE* instance) *ruleptr++ = '\0'; tok = strtok_r(modeptr," ",saveptr); - if(strcmp(tok,"match") == 0){ + if(tok && strcmp(tok,"match") == 0){ tok = strtok_r(NULL," ",saveptr); if(strcmp(tok,"any") == 0){ match_any = true; @@ -742,7 +742,13 @@ void link_rules(char* rule, FW_INSTANCE* instance) userptr = strtok_r(NULL," ",saveptr); } - + + while(rulelist) + { + RULELIST *tmp = rulelist; + rulelist = rulelist->next; + free(tmp); + } } @@ -756,7 +762,7 @@ void parse_rule(char* rule, FW_INSTANCE* instance) ss_dassert(rule != NULL && instance != NULL); char *rulecpy = strdup(rule); - char **saveptr; + char **saveptr = NULL; char *tok = strtok_r(rulecpy," ,",saveptr); bool allow,deny,mode; RULE* ruledef = NULL; @@ -800,6 +806,11 @@ void parse_rule(char* rule, FW_INSTANCE* instance) add_users(rule, instance); goto retblock; } + else + { + skygw_log_write(LOGFILE_ERROR,"Error : Unknown token in rule file: %s",tok); + goto retblock; + } tok = strtok_r(NULL, " ,",saveptr);