fix xx_plugin key length
This commit is contained in:
@@ -212,8 +212,8 @@ void bool_plugin_runtime_free(void *bool_plugin_runtime)
|
||||
}
|
||||
|
||||
int bool_plugin_runtime_update_row(struct bool_plugin_runtime *bool_plugin_rt,
|
||||
struct ex_data_schema *ex_schema,
|
||||
const char *row, char *key, size_t key_len,
|
||||
struct ex_data_schema *ex_schema, const char *row,
|
||||
const char *key, size_t key_len,
|
||||
struct bool_expr *expr, int is_valid)
|
||||
{
|
||||
int ret = -1;
|
||||
@@ -360,16 +360,18 @@ int bool_plugin_runtime_update(void *bool_plugin_runtime, void *bool_plugin_sche
|
||||
struct bool_expr *bool_expr = NULL;
|
||||
struct bool_plugin_schema *schema = (struct bool_plugin_schema *)bool_plugin_schema;
|
||||
struct bool_plugin_runtime *bool_plugin_rt = (struct bool_plugin_runtime *)bool_plugin_runtime;
|
||||
long long item_id = get_column_value(line, schema->item_id_column);
|
||||
if (item_id < 0) {
|
||||
return -1;
|
||||
}
|
||||
size_t item_id_offset = 0, item_id_len = 0;
|
||||
|
||||
int is_valid = get_column_value(line, valid_column);
|
||||
if (is_valid < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct ex_data_schema *ex_schema = schema->ex_schema;
|
||||
if (ex_schema != NULL) {
|
||||
if (1 == is_valid) {
|
||||
@@ -380,9 +382,10 @@ int bool_plugin_runtime_update(void *bool_plugin_runtime, void *bool_plugin_sche
|
||||
}
|
||||
}
|
||||
|
||||
char *key = (char *)&item_id;
|
||||
int ret = bool_plugin_runtime_update_row(bool_plugin_rt, ex_schema, line, key,
|
||||
sizeof(long long), bool_expr, is_valid);
|
||||
const char *key = line + item_id_offset;
|
||||
size_t key_len = item_id_len;
|
||||
ret = bool_plugin_runtime_update_row(bool_plugin_rt, ex_schema, line, key, key_len,
|
||||
bool_expr, is_valid);
|
||||
if (ret < 0) {
|
||||
if (bool_expr != NULL) {
|
||||
bool_plugin_expr_free(bool_expr);
|
||||
|
||||
@@ -341,16 +341,18 @@ int fqdn_plugin_runtime_update(void *fqdn_plugin_runtime, void *fqdn_plugin_sche
|
||||
struct FQDN_rule *fqdn_plugin_rule = NULL;
|
||||
struct fqdn_plugin_schema *schema = (struct fqdn_plugin_schema *)fqdn_plugin_schema;
|
||||
struct fqdn_plugin_runtime *fqdn_plugin_rt = (struct fqdn_plugin_runtime *)fqdn_plugin_runtime;
|
||||
long long item_id = get_column_value(line, schema->item_id_column);
|
||||
if (item_id < 0) {
|
||||
return -1;
|
||||
}
|
||||
size_t item_id_offset = 0, item_id_len = 0;
|
||||
|
||||
int is_valid = get_column_value(line, valid_column);
|
||||
if (is_valid < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct ex_data_schema *ex_schema = schema->ex_schema;
|
||||
if (ex_schema != NULL) {
|
||||
if (1 == is_valid) {
|
||||
@@ -361,8 +363,9 @@ int fqdn_plugin_runtime_update(void *fqdn_plugin_runtime, void *fqdn_plugin_sche
|
||||
}
|
||||
}
|
||||
|
||||
char *key = (char *)&item_id;
|
||||
int ret = fqdn_plugin_runtime_update_row(fqdn_plugin_rt, ex_schema, line, key, sizeof(long long),
|
||||
const char *key = line + item_id_offset;
|
||||
size_t key_len = item_id_len;
|
||||
ret = fqdn_plugin_runtime_update_row(fqdn_plugin_rt, ex_schema, line, key, key_len,
|
||||
fqdn_plugin_rule, is_valid);
|
||||
if (ret < 0) {
|
||||
if (fqdn_plugin_rule != NULL) {
|
||||
|
||||
@@ -311,8 +311,8 @@ void ip_plugin_table_set_ex_data_schema(void *ip_plugin_schema,
|
||||
}
|
||||
|
||||
int ip_plugin_runtime_update_row(struct ip_plugin_runtime *ip_plugin_rt,
|
||||
struct ex_data_schema *ex_schema,
|
||||
const char *row, char *key, size_t key_len,
|
||||
struct ex_data_schema *ex_schema, const char *row,
|
||||
const char *key, size_t key_len,
|
||||
struct ip_rule *ip_plugin_rule, int is_valid)
|
||||
{
|
||||
int ret = -1;
|
||||
@@ -390,16 +390,18 @@ int ip_plugin_runtime_update(void *ip_plugin_runtime, void *ip_plugin_schema,
|
||||
struct ip_rule *ip_plugin_rule = NULL;
|
||||
struct ip_plugin_schema *schema = (struct ip_plugin_schema *)ip_plugin_schema;
|
||||
struct ip_plugin_runtime *ip_plugin_rt = (struct ip_plugin_runtime *)ip_plugin_runtime;
|
||||
long long item_id = get_column_value(line, schema->item_id_column);
|
||||
if (item_id < 0) {
|
||||
return -1;
|
||||
}
|
||||
size_t item_id_offset = 0, item_id_len = 0;
|
||||
|
||||
int is_valid = get_column_value(line, valid_column);
|
||||
if (is_valid < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct ex_data_schema *ex_schema = schema->ex_schema;
|
||||
if (ex_schema != NULL) {
|
||||
if (1 == is_valid) {
|
||||
@@ -410,10 +412,10 @@ int ip_plugin_runtime_update(void *ip_plugin_runtime, void *ip_plugin_schema,
|
||||
}
|
||||
}
|
||||
|
||||
char *key = (char *)&item_id;
|
||||
int ret = ip_plugin_runtime_update_row(ip_plugin_rt, ex_schema, line, key,
|
||||
sizeof(long long), ip_plugin_rule,
|
||||
is_valid);
|
||||
const char *key = line + item_id_offset;
|
||||
size_t key_len = item_id_len;
|
||||
ret = ip_plugin_runtime_update_row(ip_plugin_rt, ex_schema, line, key, key_len,
|
||||
ip_plugin_rule, is_valid);
|
||||
if (ret < 0) {
|
||||
if (ip_plugin_rule != NULL) {
|
||||
ip_plugin_rule_free(ip_plugin_rule);
|
||||
|
||||
@@ -22,12 +22,6 @@
|
||||
|
||||
#define MODULE_PLUGIN module_name_str("maat.plugin")
|
||||
|
||||
enum plugin_key_type {
|
||||
PLUGIN_KEY_TYPE_INVALID = 0,
|
||||
PLUGIN_KEY_TYPE_POINTER,
|
||||
PLUGIN_KEY_TYPE_INTEGER
|
||||
};
|
||||
|
||||
struct plugin_callback_schema {
|
||||
maat_start_callback_t *start;
|
||||
maat_update_callback_t *update;
|
||||
@@ -45,10 +39,16 @@ struct plugin_runtime {
|
||||
struct log_handle *logger;
|
||||
};
|
||||
|
||||
enum plugin_key_type {
|
||||
PLUGIN_KEY_TYPE_INVALID = 0,
|
||||
PLUGIN_KEY_TYPE_POINTER,
|
||||
PLUGIN_KEY_TYPE_INTEGER
|
||||
};
|
||||
|
||||
#define MAX_PLUGIN_PER_TABLE 32
|
||||
struct plugin_schema {
|
||||
int key_column;
|
||||
enum plugin_key_type key_type;
|
||||
int key_column;
|
||||
int rule_tag_column;
|
||||
int n_foreign;
|
||||
int foreign_columns[MAX_FOREIGN_CLMN_NUM];
|
||||
|
||||
Reference in New Issue
Block a user