kernel: bump 5.10 to 5.10.218
[openwrt/openwrt.git] / package / network / utils / nftables / patches / 0001-meta-don-t-use-non-POSIX-formats-in-strptime.patch
1 From 1af8aabccd65e11caa397c4706353075f623cd01 Mon Sep 17 00:00:00 2001
2 From: Jo-Philipp Wich <jo@mein.io>
3 Date: Mon, 8 Aug 2022 23:57:03 +0200
4 Subject: [PATCH] meta: don't use non-POSIX formats in strptime()
5
6 The current strptime() invocations in meta.c use the `%F` format which
7 is not specified by POSIX and thus unimplemented by some libc flavors
8 such as musl libc.
9
10 Replace all occurrences of `%F` with an equivalent `%Y-%m-%d` format
11 in order to be able to properly parse user supplied dates in such
12 environments.
13
14 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
15 ---
16 src/meta.c | 8 ++++----
17 1 file changed, 4 insertions(+), 4 deletions(-)
18
19 --- a/src/meta.c
20 +++ b/src/meta.c
21 @@ -399,7 +399,7 @@ static void date_type_print(const struct
22 tstamp += cur_tm->tm_gmtoff;
23
24 if ((tm = gmtime((time_t *) &tstamp)) != NULL &&
25 - strftime(timestr, sizeof(timestr) - 1, "%F %T", tm))
26 + strftime(timestr, sizeof(timestr) - 1, "%Y-%m-%d %T", tm))
27 nft_print(octx, "\"%s\"", timestr);
28 else
29 nft_print(octx, "Error converting timestamp to printed time");
30 @@ -412,11 +412,11 @@ static time_t parse_iso_date(const char
31
32 memset(&tm, 0, sizeof(struct tm));
33
34 - if (strptime(sym, "%F %T", &tm))
35 + if (strptime(sym, "%Y-%m-%d %T", &tm))
36 goto success;
37 - if (strptime(sym, "%F %R", &tm))
38 + if (strptime(sym, "%Y-%m-%d %R", &tm))
39 goto success;
40 - if (strptime(sym, "%F", &tm))
41 + if (strptime(sym, "%Y-%m-%d", &tm))
42 goto success;
43
44 return -1;