bool DSWaylandProtocolTracePrivate::protocol_rule_init(char *rule_path)
{
bool ret = false;
- char *argv[2];
+ const char *argv[2];
int argc = 2;
if(!rule_path || strlen(rule_path) <= 0)
ProtocolTrace_Rule_Set_Result result;
const char * policy = argv[1]; //allow, deny
char merge[8192] = {0,}, rule[8192] = {0,};
- int i, index=0, size_rule, apply = 0;
+ int i, index=0, size_rule, apply = 0, size_merge;
if(argc <3)
{
protocol_arguments_merge(merge, sizeof(merge), argc -2, &(argv[2]));
size_rule = sizeof(rule) -1;
+ size_merge = strlen(merge);
- for(i=0; i<strlen(merge); i++)
+ for(i=0; i<size_merge; i++)
{
if(merge[i] == '\"' || merge[i] == '\'')
{
if(apply ==0)
{
const char * plus = "|| type=reply || type=error";
- int len = MIN(size_rule - index, strlen(plus));
- strncat(rule, plus, len);
+ int size_plus = strlen(plus);
+ int len = MIN(size_rule - index, size_plus);
+ snprintf(rule, sizeof(rule), "%s", plus);
index += len;
if(index >size_rule)
return false;
while(pfs -fs < rule_len)
{
int i, new_argc =3;
- char *new_argv[3] = {"add", };
+ const char *new_argv[3] = {"add", };
char policy[64] = {0,};
char rule[1024] = {0,};
bool DSWaylandProtocolTracePrivate::protocol_rule_validate(ProtocolTrace_Protocol_Log *log)
{
- char *cmd = "";
+ const char *cmd = "";
if(!rc)
return false;
return PROTOCOLTRACE_RULE_SET_OK;
}
-int DSWaylandProtocolTracePrivate::rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, char *cmd)
+int DSWaylandProtocolTracePrivate::rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, const char *cmd)
{
ProtocolTrace_Validate_Args args = {type, target_id, name, pid, cmd};
ProtocolTrace_Tree_Node *node;
return default_policy == PROTOCOLTRACE_TYPE_ALLOW;
}
-int DSWaylandProtocolTracePrivate::rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, char *str1)
+int DSWaylandProtocolTracePrivate::rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, const char *str1)
{
int result = strcasecmp(str2, str1);
{
ProtocolTrace_Reply_Buffer *buffer = (ProtocolTrace_Reply_Buffer *)arg;
char *reply = *buffer->reply;
- int *len = buffer->len;
- char *operators[] = {"==", "<", ">", "<=", ">=", "!=" };
+ //int *len = buffer->len;
+ const char *operators[] = {"==", "<", ">", "<=", ">=", "!=" };
ProtocolTrace_Rule_Node *data;
data = (ProtocolTrace_Rule_Node *)bintree_get_node_data(node);
}
if(msg)
{
- int min = MIN(sizeof(iface)-1, msg-args->name);
+ int size_iface = sizeof(iface) -1;
+ int min = MIN(size_iface, msg-args->name);
strncpy(iface, args->name, min);
iface[min] = '\0';
msg++;
}
if(!strcasecmp(data->variable_name, "TYPE"))
{
- char *type_string;
+ const char *type_string;
if(args->type == 0)
type_string = "REQUEST";
else if(args->type == 1)
}
else if(!strcasecmp(data->variable_name, "IFACE"))
{
- if(msg && iface[0] && rulechecker_string_compare(data->comparer, data->value.string, iface))
+ if(msg && iface[0] && rulechecker_string_compare(data->comparer, data->value.string, (const char *)iface))
data->result = PROTOCOLTRACE_RESULT_TRUE;
else
data->result = PROTOCOLTRACE_RESULT_FALSE;
#include <wayland-util.h>
#include <cstring>
-#define PATH_MAX 255 //tmp 255
+#define PATH_MAX 512
#ifndef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
int target_id;
const char *name;
int pid;
- char *cmd;
+ const char *cmd;
} ProtocolTrace_Validate_Args;
typedef struct
ProtocolTrace_Rule_Set_Result rulechecker_rule_add(_ProtocolTrace_Rule_Checker *rc, ProtocolTrace_Policy_Type policy, const char *rule_string);
void rulechecker_rule_print(ProtocolTrace_Rule_Checker *rc);
ProtocolTrace_Rule_Set_Result rulechecker_rule_remove(ProtocolTrace_Rule_Checker *rc, int index);
- static int rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, char *cmd);
- static int rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, char *str1);
+ static int rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, const char *cmd);
+ static int rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, const char *str1);
const char * rulechecker_usage_print();
static int rule_print_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg);
static int rule_validate_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg);