summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Martynov <mar.kolya@gmail.com>2013-10-31 00:34:31 -0400
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2013-11-11 21:51:13 +0100
commit2a2d4ed1c7fc50cec09b4b95013aebc9f28d205e (patch)
tree7f2be3eb91d1f68643005b4a2584f9bf6190257c
parentc3ad11037681e46fb5f3096c5c824f3e3556522a (diff)
ipset: fix timeout data type size
Currently it is impossible to set timeout on some architectures (MIPS ar71xx at least) because timeout is parsed into long long data type but used as uint32 without proper conversion. This patch fixes this issue. Tested on ar71xx router. Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com> Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
-rw-r--r--lib/parse.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/parse.c b/lib/parse.c
index 8ea8542..440ef8f 100644
--- a/lib/parse.c
+++ b/lib/parse.c
@@ -1292,15 +1292,20 @@ ipset_parse_timeout(struct ipset_session *session,
enum ipset_opt opt, const char *str)
{
int err;
- unsigned long long num = 0;
+ unsigned long long llnum = 0;
+ uint32_t num = 0;
assert(session);
assert(opt == IPSET_OPT_TIMEOUT);
assert(str);
- err = string_to_number_ll(session, str, 0, UINT_MAX/1000, &num);
- if (err == 0)
+ err = string_to_number_ll(session, str, 0, UINT_MAX/1000, &llnum);
+ if (err == 0) {
+ /* Timeout is expected to be 32bits wide, so we have
+ to convert it here */
+ num = llnum;
return ipset_session_data_set(session, opt, &num);
+ }
return err;
}