aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-08-09 00:05:02 +0200
committerJo-Philipp Wich <jo@mein.io>2022-08-25 10:30:46 +0200
commit469db326ac60f619a05eb86bcce2183cf5abf973 (patch)
tree97176d6942db413f223302fa5a752021187acd22
parentfd268e39739d13acb90843ad5ffb1443e5158a5a (diff)
downloadupstream-469db326ac60f619a05eb86bcce2183cf5abf973.tar.gz
upstream-469db326ac60f619a05eb86bcce2183cf5abf973.tar.bz2
upstream-469db326ac60f619a05eb86bcce2183cf5abf973.zip
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: #10419 Signed-off-by: Jo-Philipp Wich <jo@mein.io> (backported from commit e6e4f979999393825370e9db9fe04d75cb01acf2)
-rw-r--r--package/network/utils/nftables/Makefile2
-rw-r--r--package/network/utils/nftables/patches/0001-meta-don-t-use-non-POSIX-formats-in-strptime.patch44
2 files changed, 45 insertions, 1 deletions
diff --git a/package/network/utils/nftables/Makefile b/package/network/utils/nftables/Makefile
index 8f0fddaa0e..b9e896a9f7 100644
--- a/package/network/utils/nftables/Makefile
+++ b/package/network/utils/nftables/Makefile
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=nftables
PKG_VERSION:=1.0.2
-PKG_RELEASE:=2
+PKG_RELEASE:=2.1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://netfilter.org/projects/$(PKG_NAME)/files
diff --git a/package/network/utils/nftables/patches/0001-meta-don-t-use-non-POSIX-formats-in-strptime.patch b/package/network/utils/nftables/patches/0001-meta-don-t-use-non-POSIX-formats-in-strptime.patch
new file mode 100644
index 0000000000..12cac8cc06
--- /dev/null
+++ b/package/network/utils/nftables/patches/0001-meta-don-t-use-non-POSIX-formats-in-strptime.patch
@@ -0,0 +1,44 @@
+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(-)
+
+--- a/src/meta.c
++++ b/src/meta.c
+@@ -399,7 +399,7 @@ static void date_type_print(const struct
+ 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 time_t parse_iso_date(const char
+
+ 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 -1;