summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>2013-06-26 13:37:12 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-06-27 19:38:17 +0200
commit1f0aa8e3fe218276c64d7412b6053069bf789155 (patch)
treefd5e96d352b14fb81393044a515a34bd72c95a76 /src
parent901fb07e6281be04521440f4581a90c54caf849a (diff)
data_reg: xml: fix len node, it should show byte length
Previous to this patch, the <len> node was 'how many <dataN> nodes we have'. However, the <len> node means 'how many bytes are in <dataN> nodes'. Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/expr/data_reg.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c
index 5eb7f38..b8b8d66 100644
--- a/src/expr/data_reg.c
+++ b/src/expr/data_reg.c
@@ -132,7 +132,7 @@ static int nft_data_reg_value_xml_parse(union nft_data_reg *reg, char *xml)
{
mxml_node_t *tree = NULL;
mxml_node_t *node = NULL;
- int i, len;
+ int i;
int64_t tmp;
uint64_t utmp;
char *endptr;
@@ -152,7 +152,7 @@ static int nft_data_reg_value_xml_parse(union nft_data_reg *reg, char *xml)
/*
* <data_reg type="value">
- * <len>4</len>
+ * <len>16</len>
* <data0>0xc09a002a</data0>
* <data1>0x2700cac1</data1>
* <data2>0x00000000</data2>
@@ -183,11 +183,11 @@ static int nft_data_reg_value_xml_parse(union nft_data_reg *reg, char *xml)
mxmlDelete(tree);
return -1;
}
- /* maybe also (len < 1 || len > 4) */
- len = tmp;
+
+ reg->len = tmp;
/* Get and set <dataN> */
- for (i = 0; i < len; i++) {
+ for (i = 0; i < reg->len/sizeof(uint32_t); i++) {
sprintf(node_name, "data%d", i);
node = mxmlFindElement(tree, tree, node_name, NULL,
@@ -205,7 +205,6 @@ static int nft_data_reg_value_xml_parse(union nft_data_reg *reg, char *xml)
reg->val[i] = utmp;
}
- reg->len = sizeof(reg->val);
mxmlDelete(tree);
return 0;
@@ -265,7 +264,7 @@ int nft_data_reg_value_snprintf_xml(char *buf, size_t size,
ret = snprintf(buf, len, "<data_reg type=\"value\">");
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
- ret = snprintf(buf+offset, len, "<len>%d</len>", data_len);
+ ret = snprintf(buf+offset, len, "<len>%zd</len>", reg->len);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
for (i=0; i<data_len; i++) {