projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2807 from sileht/master
[collectd.git]
/
src
/
iptables.c
diff --git
a/src/iptables.c
b/src/iptables.c
index
1d127bf
..
225ed2c
100644
(file)
--- a/
src/iptables.c
+++ b/
src/iptables.c
@@
-86,8
+86,8
@@
typedef struct {
char name[64];
} ip_chain_t;
char name[64];
} ip_chain_t;
-static ip_chain_t **chain_list
= NULL
;
-static int chain_num
= 0
;
+static ip_chain_t **chain_list;
+static int chain_num;
static int iptables_config(const char *key, const char *value) {
/* int ip_value; */
static int iptables_config(const char *key, const char *value) {
/* int ip_value; */
@@
-101,11
+101,9
@@
static int iptables_config(const char *key, const char *value) {
return 1;
ip_chain_t temp = {0};
return 1;
ip_chain_t temp = {0};
- ip_chain_t *
final, **list;
+ ip_chain_t *final, **list;
char *table;
char *table;
- int table_len;
char *chain;
char *chain;
- int chain_len;
char *value_copy;
char *fields[4];
char *value_copy;
char *fields[4];
@@
-113,8
+111,7
@@
static int iptables_config(const char *key, const char *value) {
value_copy = strdup(value);
if (value_copy == NULL) {
value_copy = strdup(value);
if (value_copy == NULL) {
- char errbuf[1024];
- ERROR("strdup failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("strdup failed: %s", STRERRNO);
return 1;
}
return 1;
}
@@
-137,16
+134,16
@@
static int iptables_config(const char *key, const char *value) {
table = fields[0];
chain = fields[1];
table = fields[0];
chain = fields[1];
- table_len = strlen(table) + 1;
- if (
(unsigned int)
table_len > sizeof(temp.table)) {
+
size_t
table_len = strlen(table) + 1;
+ if (table_len > sizeof(temp.table)) {
ERROR("Table `%s' too long.", table);
free(value_copy);
return 1;
}
sstrncpy(temp.table, table, table_len);
ERROR("Table `%s' too long.", table);
free(value_copy);
return 1;
}
sstrncpy(temp.table, table, table_len);
- chain_len = strlen(chain) + 1;
- if (
(unsigned int)
chain_len > sizeof(temp.chain)) {
+
size_t
chain_len = strlen(chain) + 1;
+ if (chain_len > sizeof(temp.chain)) {
ERROR("Chain `%s' too long.", chain);
free(value_copy);
return 1;
ERROR("Chain `%s' too long.", chain);
free(value_copy);
return 1;
@@
-182,17
+179,15
@@
static int iptables_config(const char *key, const char *value) {
list = realloc(chain_list, (chain_num + 1) * sizeof(ip_chain_t *));
if (list == NULL) {
list = realloc(chain_list, (chain_num + 1) * sizeof(ip_chain_t *));
if (list == NULL) {
- char errbuf[1024];
- ERROR("realloc failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("realloc failed: %s", STRERRNO);
sfree(temp.rule.comment);
return 1;
}
chain_list = list;
sfree(temp.rule.comment);
return 1;
}
chain_list = list;
- final = malloc(sizeof(*
final));
+ final = malloc(sizeof(*final));
if (final == NULL) {
if (final == NULL) {
- char errbuf[1024];
- ERROR("malloc failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("malloc failed: %s", STRERRNO);
sfree(temp.rule.comment);
return 1;
}
sfree(temp.rule.comment);
return 1;
}
@@
-226,8
+221,8
@@
static int submit6_match(const struct ip6t_entry_match *match,
sstrncpy(vl.plugin, "ip6tables", sizeof(vl.plugin));
sstrncpy(vl.plugin, "ip6tables", sizeof(vl.plugin));
- status = s
s
nprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s",
-
chain->table, chain->chain);
+ status = snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s",
+ chain->table, chain->chain);
if ((status < 1) || ((unsigned int)status >= sizeof(vl.plugin_instance)))
return 0;
if ((status < 1) || ((unsigned int)status >= sizeof(vl.plugin_instance)))
return 0;
@@
-235,8
+230,8
@@
static int submit6_match(const struct ip6t_entry_match *match,
sstrncpy(vl.type_instance, chain->name, sizeof(vl.type_instance));
} else {
if (chain->rule_type == RTYPE_NUM)
sstrncpy(vl.type_instance, chain->name, sizeof(vl.type_instance));
} else {
if (chain->rule_type == RTYPE_NUM)
- s
s
nprintf(vl.type_instance, sizeof(vl.type_instance), "%i",
-
chain->rule.num);
+ snprintf(vl.type_instance, sizeof(vl.type_instance), "%i",
+ chain->rule.num);
else
sstrncpy(vl.type_instance, (char *)match->data, sizeof(vl.type_instance));
}
else
sstrncpy(vl.type_instance, (char *)match->data, sizeof(vl.type_instance));
}
@@
-274,8
+269,8
@@
static int submit_match(const struct ipt_entry_match *match,
sstrncpy(vl.plugin, "iptables", sizeof(vl.plugin));
sstrncpy(vl.plugin, "iptables", sizeof(vl.plugin));
- status = s
s
nprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s",
-
chain->table, chain->chain);
+ status = snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s",
+ chain->table, chain->chain);
if ((status < 1) || ((unsigned int)status >= sizeof(vl.plugin_instance)))
return 0;
if ((status < 1) || ((unsigned int)status >= sizeof(vl.plugin_instance)))
return 0;
@@
-283,8
+278,8
@@
static int submit_match(const struct ipt_entry_match *match,
sstrncpy(vl.type_instance, chain->name, sizeof(vl.type_instance));
} else {
if (chain->rule_type == RTYPE_NUM)
sstrncpy(vl.type_instance, chain->name, sizeof(vl.type_instance));
} else {
if (chain->rule_type == RTYPE_NUM)
- s
s
nprintf(vl.type_instance, sizeof(vl.type_instance), "%i",
-
chain->rule.num);
+ snprintf(vl.type_instance, sizeof(vl.type_instance), "%i",
+ chain->rule.num);
else
sstrncpy(vl.type_instance, (char *)match->data, sizeof(vl.type_instance));
}
else
sstrncpy(vl.type_instance, (char *)match->data, sizeof(vl.type_instance));
}