* [PATCH nft] meta time: use uint64_t instead of time_t
[not found] <20220405101016.855221490@web.de>
@ 2022-04-05 10:41 ` Lukas Straub
2022-04-05 11:58 ` Pablo Neira Ayuso
2022-04-05 13:28 ` Phil Sutter
0 siblings, 2 replies; 3+ messages in thread
From: Lukas Straub @ 2022-04-05 10:41 UTC (permalink / raw)
To: netfilter-devel
[-- Attachment #1: Type: text/plain, Size: 836 bytes --]
time_t may be 32 bit on some platforms and thus can't fit a timestamp
with nanoseconds resolution. This causes overflows and ultimatively
breaks meta time expressions on such platforms.
Fix this by using uint64_t instead.
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1567
Fixes: f8f32deda31df597614d9f1f64ffb0c0320f4d54
("meta: Introduce new conditions 'time', 'day' and 'hour'")
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
Index: b/src/meta.c
===================================================================
--- a/src/meta.c
+++ b/src/meta.c
@@ -444,7 +444,7 @@ static struct error_record *date_type_pa
struct expr **res)
{
const char *endptr = sym->identifier;
- time_t tstamp;
+ uint64_t tstamp;
if ((tstamp = parse_iso_date(sym->identifier)) != -1)
goto success;
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH nft] meta time: use uint64_t instead of time_t
2022-04-05 10:41 ` [PATCH nft] meta time: use uint64_t instead of time_t Lukas Straub
@ 2022-04-05 11:58 ` Pablo Neira Ayuso
2022-04-05 13:28 ` Phil Sutter
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-05 11:58 UTC (permalink / raw)
To: Lukas Straub; +Cc: netfilter-devel
On Tue, Apr 05, 2022 at 10:41:14AM +0000, Lukas Straub wrote:
> time_t may be 32 bit on some platforms and thus can't fit a timestamp
> with nanoseconds resolution. This causes overflows and ultimatively
> breaks meta time expressions on such platforms.
>
> Fix this by using uint64_t instead.
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH nft] meta time: use uint64_t instead of time_t
2022-04-05 10:41 ` [PATCH nft] meta time: use uint64_t instead of time_t Lukas Straub
2022-04-05 11:58 ` Pablo Neira Ayuso
@ 2022-04-05 13:28 ` Phil Sutter
1 sibling, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2022-04-05 13:28 UTC (permalink / raw)
To: Lukas Straub; +Cc: netfilter-devel
On Tue, Apr 05, 2022 at 10:41:14AM +0000, Lukas Straub wrote:
> time_t may be 32 bit on some platforms and thus can't fit a timestamp
> with nanoseconds resolution. This causes overflows and ultimatively
> breaks meta time expressions on such platforms.
>
> Fix this by using uint64_t instead.
>
> Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1567
> Fixes: f8f32deda31df597614d9f1f64ffb0c0320f4d54
> ("meta: Introduce new conditions 'time', 'day' and 'hour'")
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>
>
> Index: b/src/meta.c
> ===================================================================
> --- a/src/meta.c
> +++ b/src/meta.c
> @@ -444,7 +444,7 @@ static struct error_record *date_type_pa
> struct expr **res)
> {
> const char *endptr = sym->identifier;
> - time_t tstamp;
> + uint64_t tstamp;
>
> if ((tstamp = parse_iso_date(sym->identifier)) != -1)
Doesn't this introduce a warning due to signed/unsigned comparison?
I guess you'll have to cast -1 to uint64_t as well.
Cheers, Phil
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-05 21:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20220405101016.855221490@web.de>
2022-04-05 10:41 ` [PATCH nft] meta time: use uint64_t instead of time_t Lukas Straub
2022-04-05 11:58 ` Pablo Neira Ayuso
2022-04-05 13:28 ` Phil Sutter
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.