diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-08-09 00:18:42 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-08-09 10:51:43 +0200 |
commit | 180ce4d7da785d93ce2b070a2b45b82088d09c10 (patch) | |
tree | 9058ed772c1660f3a53172a3af775ac0c1aee892 /src/meta.c | |
parent | c1c223f1b58188542222ee2d9a4a8cc133d1dc3b (diff) |
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/meta.c')
-rw-r--r-- | src/meta.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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; |