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()
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
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
14 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
16 src/meta.c | 8 ++++----
17 1 file changed, 4 insertions(+), 4 deletions(-)
19 diff --git a/src/meta.c b/src/meta.c
20 index 80ace25b..257bbc9f 100644
23 @@ -399,7 +399,7 @@ static void date_type_print(const struct expr *expr, struct output_ctx *octx)
24 tstamp += cur_tm->tm_gmtoff;
26 if ((tm = gmtime((time_t *) &tstamp)) != NULL &&
27 - strftime(timestr, sizeof(timestr) - 1, "%F %T", tm))
28 + strftime(timestr, sizeof(timestr) - 1, "%Y-%m-%d %T", tm))
29 nft_print(octx, "\"%s\"", timestr);
31 nft_print(octx, "Error converting timestamp to printed time");
32 @@ -412,11 +412,11 @@ static bool parse_iso_date(uint64_t *tstamp, const char *sym)
34 memset(&tm, 0, sizeof(struct tm));
36 - if (strptime(sym, "%F %T", &tm))
37 + if (strptime(sym, "%Y-%m-%d %T", &tm))
39 - if (strptime(sym, "%F %R", &tm))
40 + if (strptime(sym, "%Y-%m-%d %R", &tm))
42 - if (strptime(sym, "%F", &tm))
43 + if (strptime(sym, "%Y-%m-%d", &tm))