[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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Jan Engelhardt and committed by David S. Miller 4f4c9430 7000d38d

+5 -2
+5 -2
net/netfilter/xt_time.c
··· 95 */ 96 r->dse = time / 86400; 97 98 - /* 1970-01-01 (w=0) was a Thursday (4). */ 99 - r->weekday = (4 + r->dse) % 7; 100 } 101 102 static void localtime_3(struct xtm *r, time_t time)
··· 95 */ 96 r->dse = time / 86400; 97 98 + /* 99 + * 1970-01-01 (w=0) was a Thursday (4). 100 + * -1 and +1 map Sunday properly onto 7. 101 + */ 102 + r->weekday = (4 + r->dse - 1) % 7 + 1; 103 } 104 105 static void localtime_3(struct xtm *r, time_t time)