Merge branch 'release-1.3.0' into develop

This commit is contained in:
Markus Makela
2016-01-08 11:14:02 +02:00
46 changed files with 349 additions and 257 deletions

View File

@ -11,7 +11,7 @@ if(BUILD_RABBITMQ)
endif()
add_library(regexfilter SHARED regexfilter.c)
target_link_libraries(regexfilter log_manager ${PCRE2_LIBRARIES})
target_link_libraries(regexfilter log_manager)
add_dependencies(regexfilter pcre2)
set_target_properties(regexfilter PROPERTIES VERSION "1.1.0")
install(TARGETS regexfilter DESTINATION ${MAXSCALE_LIBDIR})

View File

@ -998,7 +998,7 @@ bool parse_rule_definition(FW_INSTANCE* instance, RULE* ruledef, char* rule, cha
{
bool escaped = false;
regex_t *re;
char* start, *str;
char* start;
tok = strtok_r(NULL, " ", saveptr);
char delim = '\'';
int n_char = 0;
@ -1052,20 +1052,13 @@ bool parse_rule_definition(FW_INSTANCE* instance, RULE* ruledef, char* rule, cha
goto retblock;
}
str = calloc(((tok - start) + 1), sizeof(char));
if (str == NULL)
{
MXS_ERROR("Fatal Error: malloc returned NULL.");
rval = false;
goto retblock;
}
char str[(tok - start) + 1];
re = (regex_t*) malloc(sizeof(regex_t));
if (re == NULL)
{
MXS_ERROR("Fatal Error: malloc returned NULL.");
rval = false;
free(str);
goto retblock;
}
@ -1083,7 +1076,6 @@ bool parse_rule_definition(FW_INSTANCE* instance, RULE* ruledef, char* rule, cha
ruledef->type = RT_REGEX;
ruledef->data = (void*) re;
}
free(str);
}
else if (strcmp(tok, "limit_queries") == 0)
@ -1277,11 +1269,8 @@ createInstance(char **options, FILTER_PARAMETER **params)
{
if (strcmp(params[i]->name, "rules") == 0)
{
if (filename)
{
free(filename);
}
filename = strdup(params[i]->value);
filename = params[i]->value;
break;
}
}
@ -1292,6 +1281,7 @@ createInstance(char **options, FILTER_PARAMETER **params)
if (strcmp(options[i], "ignorecase") == 0)
{
my_instance->regflags |= REG_ICASE;
break;
}
}
}
@ -1310,7 +1300,6 @@ createInstance(char **options, FILTER_PARAMETER **params)
MXS_ERROR("Error while opening rule file for firewall filter.");
hashtable_free(my_instance->htable);
free(my_instance);
free(filename);
return NULL;
}
@ -1360,16 +1349,15 @@ createInstance(char **options, FILTER_PARAMETER **params)
if (file_empty)
{
MXS_ERROR("dbfwfilter: File is empty: %s", filename);
free(filename);
err = true;
goto retblock;
}
fclose(file);
free(filename);
/**Apply the rules to users*/
ptr = my_instance->userstrings;
my_instance->userstrings = NULL;
if (ptr == NULL)
{
@ -2205,6 +2193,10 @@ bool parse_at_times(const char** tok, char** saveptr, RULE* ruledef)
{
ruledef->active = tr;
}
else
{
free(tr);
}
return success;
}

View File

@ -502,7 +502,7 @@ createInstance(char **options, FILTER_PARAMETER **params)
MQ_INSTANCE *my_instance;
int paramcount = 0, parammax = 64, i = 0, x = 0, arrsize = 0;
FILTER_PARAMETER** paramlist;
char** arr;
char** arr = NULL;
char taskname[512];
if ((my_instance = calloc(1, sizeof(MQ_INSTANCE))))
@ -514,6 +514,8 @@ createInstance(char **options, FILTER_PARAMETER **params)
if ((my_instance->conn = amqp_new_connection()) == NULL)
{
free(paramlist);
free(my_instance);
return NULL;
}
my_instance->channel = 1;
@ -610,6 +612,10 @@ createInstance(char **options, FILTER_PARAMETER **params)
if (arrsize > 0)
{
for (int x = 0; x < arrsize; x++)
{
free(arr[x]);
}
free(arr);
}
arrsize = 0;
@ -777,7 +783,11 @@ createInstance(char **options, FILTER_PARAMETER **params)
snprintf(taskname, 511, "mqtask%d", atomic_add(&hktask_id, 1));
hktask_add(taskname, sendMessage, (void*) my_instance, 5);
for (int x = 0; x < arrsize; x++)
{
free(arr[x]);
}
free(arr);
}
return(FILTER *) my_instance;
}
@ -834,7 +844,7 @@ void sendMessage(void* data)
{
MQ_INSTANCE *instance = (MQ_INSTANCE*) data;
mqmessage *tmp;
int err_num;
int err_num = AMQP_STATUS_OK;
spinlock_acquire(&instance->rconn_lock);
if (instance->conn_stat != AMQP_STATUS_OK)

View File

@ -391,7 +391,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
REGEX_SESSION *my_session = (REGEX_SESSION *) session;
char *sql, *newsql;
if (modutil_is_SQL(queue))
if (my_session->active && modutil_is_SQL(queue))
{
if (queue->next != NULL)
{