static int target_to_verdict(const char *target_name)
{
- if (!strcmp(target_name, LABEL_ACCEPT))
+ if (!g_strcmp0(target_name, LABEL_ACCEPT))
return -NF_ACCEPT - 1;
- if (!strcmp(target_name, LABEL_DROP))
+ if (!g_strcmp0(target_name, LABEL_DROP))
return -NF_DROP - 1;
- if (!strcmp(target_name, LABEL_QUEUE))
+ if (!g_strcmp0(target_name, LABEL_QUEUE))
return -NF_QUEUE - 1;
- if (!strcmp(target_name, LABEL_RETURN))
+ if (!g_strcmp0(target_name, LABEL_RETURN))
return XT_RETURN;
return 0;
static gboolean is_builtin_target(const char *target_name)
{
- if (!strcmp(target_name, LABEL_ACCEPT) ||
- !strcmp(target_name, LABEL_DROP) ||
- !strcmp(target_name, LABEL_QUEUE) ||
- !strcmp(target_name, LABEL_RETURN))
+ if (!g_strcmp0(target_name, LABEL_ACCEPT) ||
+ !g_strcmp0(target_name, LABEL_DROP) ||
+ !g_strcmp0(target_name, LABEL_QUEUE) ||
+ !g_strcmp0(target_name, LABEL_RETURN))
return TRUE;
return FALSE;
target = ipt_get_target(e->entry);
- if (!strcmp(target->u.user.name, IPT_STANDARD_TARGET)) {
+ if (!g_strcmp0(target->u.user.name, IPT_STANDARD_TARGET)) {
struct xt_standard_target *t;
t = (struct xt_standard_target *)target;
return TRUE;
target = ipt_get_target(entry);
- if (!strcmp(target->u.user.name, IPT_ERROR_TARGET))
+ if (!g_strcmp0(target->u.user.name, IPT_ERROR_TARGET))
return TRUE;
return FALSE;
/* Buit-in chain */
builtin = head->builtin;
- if (builtin >= 0 && !strcmp(hooknames[builtin], chain_name))
+ if (builtin >= 0 && !g_strcmp0(hooknames[builtin], chain_name))
break;
/* User defined chain */
target = ipt_get_target(entry);
- if (!strcmp(target->u.user.name, IPT_ERROR_TARGET) &&
- !strcmp((char *)target->data, chain_name))
+ if (!g_strcmp0(target->u.user.name, IPT_ERROR_TARGET) &&
+ !g_strcmp0((char *)target->data, chain_name))
break;
}
entry_head->next_offset = entry_head_size;
error = (struct error_target *) entry_head->elems;
- strcpy(error->t.u.user.name, IPT_ERROR_TARGET);
+ g_stpcpy(error->t.u.user.name, IPT_ERROR_TARGET);
error->t.u.user.target_size = ALIGN(sizeof(struct error_target));
- strcpy(error->error, name);
+ g_stpcpy(error->error, name);
if (iptables_add_entry(table, entry_head, last, -1) < 0)
goto err_head;
if (xt_e_t1 == NULL || xt_e_t2 == NULL)
return FALSE;
- if (strcmp(xt_e_t1->u.user.name, "") == 0 &&
- strcmp(xt_e_t2->u.user.name, "") == 0) {
+ if (g_strcmp0(xt_e_t1->u.user.name, "") == 0 &&
+ g_strcmp0(xt_e_t2->u.user.name, "") == 0) {
/* fallthrough */
return TRUE;
- } else if (strcmp(xt_e_t1->u.user.name, IPT_STANDARD_TARGET) == 0) {
+ } else if (g_strcmp0(xt_e_t1->u.user.name, IPT_STANDARD_TARGET) == 0) {
struct xt_standard_target *xt_s_t1;
struct xt_standard_target *xt_s_t2;
if (xt_e_t1->u.target_size != xt_e_t2->u.target_size)
return FALSE;
- if (strcmp(xt_e_t1->u.user.name, xt_e_t2->u.user.name) != 0)
+ if (g_strcmp0(xt_e_t1->u.user.name, xt_e_t2->u.user.name) != 0)
return FALSE;
for (i = 0; i < xt_e_t1->u.target_size -
if (xt_e_m1->u.user.revision != xt_e_m2->u.user.revision)
return FALSE;
- if (strcmp(xt_e_m1->u.user.name, xt_e_m2->u.user.name) != 0)
+ if (g_strcmp0(xt_e_m1->u.user.name, xt_e_m2->u.user.name) != 0)
return FALSE;
for (i = 0; i < xt_e_m1->u.match_size - sizeof(struct xt_entry_match);
return NULL;
}
- strcpy(r->name, table->info->name);
+ g_stpcpy(r->name, table->info->name);
r->num_entries = table->num_entries;
r->size = table->size;
target = ipt_get_target(entry);
- if (!strcmp(target->u.user.name, IPT_STANDARD_TARGET)) {
+ if (!g_strcmp0(target->u.user.name, IPT_STANDARD_TARGET)) {
struct xt_standard_target *t;
t = (struct xt_standard_target *)target;
return 0;
}
- if (!strcmp(target->u.user.name, IPT_ERROR_TARGET)) {
+ if (!g_strcmp0(target->u.user.name, IPT_ERROR_TARGET)) {
DBG("\tUSER CHAIN (%s) match %p target %p",
target->data, entry->elems,
(char *)entry + entry->target_offset);
goto err;
s = sizeof(*table->info);
- strcpy(table->info->name, table_name);
+ g_stpcpy(table->info->name, table_name);
if (getsockopt(table->ipt_sock, IPPROTO_IP, IPT_SO_GET_INFO,
table->info, &s) < 0) {
connman_error("iptables support missing error %d (%s)", errno,
if (table->blob_entries == NULL)
goto err;
- strcpy(table->blob_entries->name, table_name);
+ g_stpcpy(table->blob_entries->name, table_name);
table->blob_entries->size = table->info->size;
if (iptables_get_entries(table) < 0)
struct xt_standard_target *target;
target = (struct xt_standard_target *)(xt_t->t);
- strcpy(target->target.u.user.name, IPT_STANDARD_TARGET);
+ g_stpcpy(target->target.u.user.name, IPT_STANDARD_TARGET);
if (is_builtin == TRUE)
target->verdict = target_to_verdict(target_name);
target->verdict = target_rule->offset;
}
} else {
- strcpy(xt_t->t->u.user.name, target_name);
+ g_stpcpy(xt_t->t->u.user.name, target_name);
xt_t->t->u.user.revision = xt_t->revision;
if (xt_t->init != NULL)
xt_t->init(xt_t->t);
return NULL;
xt_m->m->u.match_size = match_size;
- strcpy(xt_m->m->u.user.name, xt_m->name);
+ g_stpcpy(xt_m->m->u.user.name, xt_m->name);
xt_m->m->u.user.revision = xt_m->revision;
if (xt_m->init != NULL)
if (len + 1 > IFNAMSIZ)
break;
- strcpy(ctx->ip->iniface, optarg);
+ g_stpcpy(ctx->ip->iniface, optarg);
memset(ctx->ip->iniface_mask, 0xff, len + 1);
if (invert)
if (len + 1 > IFNAMSIZ)
break;
- strcpy(ctx->ip->outiface, optarg);
+ g_stpcpy(ctx->ip->outiface, optarg);
memset(ctx->ip->outiface_mask, 0xff, len + 1);
if (invert)
target = ipt_get_target(entry);
- if (!strcmp(target->u.user.name, IPT_ERROR_TARGET))
+ if (!g_strcmp0(target->u.user.name, IPT_ERROR_TARGET))
name = g_strdup((const char*)target->data);
else if (builtin >= 0)
name = g_strdup(hooknames[builtin]);