summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-03-05 14:53:38 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2013-03-05 14:58:11 +0100
commitc768dd3b32daf2a966a72b4cc81f12f9b66a0886 (patch)
tree1f23dddc39acd104a1372b06f183709cf470afc1 /src
parent316b0059c60f8763f3b069f09223d3ba5685b633 (diff)
nfacct: fix packet and bytes counters length in restore operation
They are 64 bits long, not 32 bits long. Based on patch from Mr Dash Four. Reported-by: Mr Dash Four <mr.dash.four@googlemail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/nfacct.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nfacct.c b/src/nfacct.c
index 4ce817d..2ef93c3 100644
--- a/src/nfacct.c
+++ b/src/nfacct.c
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <inttypes.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
@@ -218,7 +219,7 @@ static int nfacct_cmd_list(int argc, char *argv[])
return 0;
}
-static int _nfacct_cmd_add(char *name, int pkts, int bytes)
+static int _nfacct_cmd_add(char *name, uint64_t pkts, uint64_t bytes)
{
struct mnl_socket *nl;
char buf[MNL_SOCKET_BUFFER_SIZE];
@@ -529,6 +530,7 @@ static int nfacct_cmd_restore(int argc, char *argv[])
char name[512];
char buffer[512];
int ret;
+
while (fgets(buffer, sizeof(buffer), stdin)) {
char *semicolon = strchr(buffer, ';');
if (semicolon == NULL) {
@@ -536,7 +538,8 @@ static int nfacct_cmd_restore(int argc, char *argv[])
return -1;
}
*semicolon = 0;
- ret = sscanf(buffer, "{ pkts = %lu, bytes = %lu } = %s",
+ ret = sscanf(buffer,
+ "{ pkts = %"PRIu64", bytes = %"PRIu64" } = %s",
&pkts, &bytes, name);
if (ret != 3) {
nfacct_perror("error reading input");