From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: Patrick McHardy <kaber@trash.net>, netfilter-devel@vger.kernel.org
Subject: [NETFILTER 04/09]: xt_time: fix failure to match on Sundays
Date: Mon, 10 Mar 2008 19:26:18 +0100 (MET) [thread overview]
Message-ID: <20080310182620.20404.70884.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080310182615.20404.67685.sendpatchset@localhost.localdomain>
[NETFILTER]: xt_time: fix failure to match on Sundays
From: Andrew Schulman <andrex@alumni.utexas.net>
xt_time_match() in net/netfilter/xt_time.c in kernel 2.6.24 never
matches on Sundays. On my host I have a rule like
iptables -A OUTPUT -m time --weekdays Sun -j REJECT
and it never matches. The problem is in localtime_2(), which uses
r->weekday = (4 + r->dse) % 7;
to map the epoch day onto a weekday in {0,...,6}. In particular this
gives 0 for Sundays. But 0 has to be wrong; a weekday of 0 can never
match. xt_time_match() has
if (!(info->weekdays_match & (1 << current_time.weekday)))
return false;
and when current_time.weekday = 0, the result of the & is always
zero, even when info->weekdays_match = XT_TIME_ALL_WEEKDAYS = 0xFE.
Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 342661f5a04f90772e0d33302634e010ab3649ed
tree 3dc6d36f9d245b9f2990ab503735904c1d8187d1
parent b306ccc2129dfc062653b3436df714fc758f3c45
author Andrew Schulman <andrex@alumni.utexas.net> Mon, 10 Mar 2008 17:50:42 +0100
committer Patrick McHardy <kaber@trash.net> Mon, 10 Mar 2008 17:50:42 +0100
net/netfilter/xt_time.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c
index e9a8794..9fa2e08 100644
--- a/net/netfilter/xt_time.c
+++ b/net/netfilter/xt_time.c
@@ -95,8 +95,11 @@ static inline void localtime_2(struct xtm *r, time_t time)
*/
r->dse = time / 86400;
- /* 1970-01-01 (w=0) was a Thursday (4). */
- r->weekday = (4 + r->dse) % 7;
+ /*
+ * 1970-01-01 (w=0) was a Thursday (4).
+ * -1 and +1 map Sunday properly onto 7.
+ */
+ r->weekday = (4 + r->dse - 1) % 7 + 1;
}
static void localtime_3(struct xtm *r, time_t time)
next prev parent reply other threads:[~2008-03-10 18:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-10 18:26 [NETFILTER 00/09]: Netfilter fixes Patrick McHardy
2008-03-10 18:26 ` [NETFILTER 01/09]: nfnetlink: fix ifdef in nfnetlink_compat.h Patrick McHardy
2008-03-10 18:26 ` [NETFILTER 02/09]: nfnetlink_queue: fix computation of allocated size for netlink skb Patrick McHardy
2008-03-10 18:26 ` [NETFILTER 03/09]: nfnetlink_log: fix computation of netlink skb size Patrick McHardy
2008-03-10 18:26 ` Patrick McHardy [this message]
2008-03-10 18:26 ` [NETFILTER 05/09]: nf_conntrack: add \n to "expectation table full" message Patrick McHardy
2008-03-10 18:26 ` [NETFILTER 06/09]: nf_conntrack: replace horrible hack with ksize() Patrick McHardy
2008-03-10 18:26 ` [NETFILTER 07/09]: nfnetlink_log: fix EPERM when binding/unbinding and instance 0 exists Patrick McHardy
2008-03-10 18:26 ` [NETFILTER 08/09]: nfnetlink_queue: " Patrick McHardy
2008-03-10 18:26 ` [NETFILTER 09/09]: nf_queue: don't return error when unregistering a non-existant handler Patrick McHardy
2008-03-10 23:45 ` [NETFILTER 00/09]: Netfilter fixes David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080310182620.20404.70884.sendpatchset@localhost.localdomain \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.