diff options
| author | Xi Wang <xi.wang@gmail.com> | 2011-12-30 10:40:17 -0500 |
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-31 10:59:04 -0500 |
| commit | c121638277a71c1e1fb44c3e654ea353357bbc2c (patch) | |
| tree | eacfd2881aa785c462587ab8173461b96c396771 | |
| parent | 52793dbe3d60bd73bbebe28b2bfc9f6b4b920d4c (diff) | |
netfilter: ctnetlink: fix timeout calculation
The sanity check (timeout < 0) never works; the dividend is unsigned
and so is the division, which should have been a signed division.
long timeout = (ct->timeout.expires - jiffies) / HZ;
if (timeout < 0)
timeout = 0;
This patch converts the time values to signed for the division.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
| -rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index b6977776d715..257e77256c5c 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
| @@ -135,7 +135,7 @@ nla_put_failure: | |||
| 135 | static inline int | 135 | static inline int |
| 136 | ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct) | 136 | ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct) |
| 137 | { | 137 | { |
| 138 | long timeout = (ct->timeout.expires - jiffies) / HZ; | 138 | long timeout = ((long)ct->timeout.expires - (long)jiffies) / HZ; |
| 139 | 139 | ||
| 140 | if (timeout < 0) | 140 | if (timeout < 0) |
| 141 | timeout = 0; | 141 | timeout = 0; |
| @@ -1641,7 +1641,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, | |||
| 1641 | const struct nf_conntrack_expect *exp) | 1641 | const struct nf_conntrack_expect *exp) |
| 1642 | { | 1642 | { |
| 1643 | struct nf_conn *master = exp->master; | 1643 | struct nf_conn *master = exp->master; |
| 1644 | long timeout = (exp->timeout.expires - jiffies) / HZ; | 1644 | long timeout = ((long)exp->timeout.expires - (long)jiffies) / HZ; |
| 1645 | struct nf_conn_help *help; | 1645 | struct nf_conn_help *help; |
| 1646 | 1646 | ||
| 1647 | if (timeout < 0) | 1647 | if (timeout < 0) |
