This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nftables: fix parsing date expressions
Musl libc does not support the non-POSIX "%F" format for strptime() so replace all occurrences of it with an equivalent "%Y-%m-%d" format. Fixes: openwrt#10419 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ge/network/utils/nftables/patches/0001-meta-don-t-use-non-POSIX-formats-in-strptime.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
From 1af8aabccd65e11caa397c4706353075f623cd01 Mon Sep 17 00:00:00 2001 | ||
From: Jo-Philipp Wich <jo@mein.io> | ||
Date: Mon, 8 Aug 2022 23:57:03 +0200 | ||
Subject: [PATCH] meta: don't use non-POSIX formats in strptime() | ||
|
||
The current strptime() invocations in meta.c use the `%F` format which | ||
is not specified by POSIX and thus unimplemented by some libc flavors | ||
such as musl libc. | ||
|
||
Replace all occurrences of `%F` with an equivalent `%Y-%m-%d` format | ||
in order to be able to properly parse user supplied dates in such | ||
environments. | ||
|
||
Signed-off-by: Jo-Philipp Wich <jo@mein.io> | ||
--- | ||
src/meta.c | 8 ++++---- | ||
1 file changed, 4 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/src/meta.c b/src/meta.c | ||
index 80ace25b..257bbc9f 100644 | ||
--- a/src/meta.c | ||
+++ b/src/meta.c | ||
@@ -399,7 +399,7 @@ static void date_type_print(const struct expr *expr, struct output_ctx *octx) | ||
tstamp += cur_tm->tm_gmtoff; | ||
|
||
if ((tm = gmtime((time_t *) &tstamp)) != NULL && | ||
- strftime(timestr, sizeof(timestr) - 1, "%F %T", tm)) | ||
+ strftime(timestr, sizeof(timestr) - 1, "%Y-%m-%d %T", tm)) | ||
nft_print(octx, "\"%s\"", timestr); | ||
else | ||
nft_print(octx, "Error converting timestamp to printed time"); | ||
@@ -412,11 +412,11 @@ static bool parse_iso_date(uint64_t *tstamp, const char *sym) | ||
|
||
memset(&tm, 0, sizeof(struct tm)); | ||
|
||
- if (strptime(sym, "%F %T", &tm)) | ||
+ if (strptime(sym, "%Y-%m-%d %T", &tm)) | ||
goto success; | ||
- if (strptime(sym, "%F %R", &tm)) | ||
+ if (strptime(sym, "%Y-%m-%d %R", &tm)) | ||
goto success; | ||
- if (strptime(sym, "%F", &tm)) | ||
+ if (strptime(sym, "%Y-%m-%d", &tm)) | ||
goto success; | ||
|
||
return false; | ||
-- | ||
2.35.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters