Skip to contentSkip to conversation

meta time: use uint64_t instead of time_t

PATCH Applied Lukas Straub 3 participants 3 messages Apr 5, 2022 1 message not in the archive netfilter

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 meta time: use uint64_t instead of time_t

In reply to a message not in the archive

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.

Fixes f8f32deda31df597614d9f1f64ffb0c0320f4d54

("meta: Introduce new conditions 'time', 'day' and 'hour'")

src/meta.c +1 -1
Index: 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;
maintainer Applied
#2 lore raw
Quoted 5 lines · Lukas Straub

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

reviewer
#3 lore raw
In reply to Lukas Straub
Quoted 16 lines · Lukas Straub

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.

Fixes f8f32deda31df597614d9f1f64ffb0c0320f4d54

("meta: Introduce new conditions 'time', 'day' and 'hour'")

Index: b/src/meta.c
===================================================================

src/meta.c static struct error_record *date_type_pa · line 449

Quoted 7 lines
src/meta.c +1 -1
@@ -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