From: Yu Watanabe Date: Tue, 8 Oct 2024 04:50:02 +0000 (+0900) Subject: time-util: copy input string before fork() X-Git-Tag: v257-rc1~296^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d3012bab4ce4c1ed260598d05b4e9f2ea471658;p=thirdparty%2Fsystemd.git time-util: copy input string before fork() Fixes #34670. --- diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 06c465e0e40..1e042b8b600 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -1043,6 +1043,14 @@ int parse_timestamp(const char *t, usec_t *ret) { if (shared == MAP_FAILED) return negative_errno(); + /* The input string may be in argv. Let's copy it. */ + _cleanup_free_ char *t_copy = strdup(t); + if (!t_copy) + return -ENOMEM; + + t = t_copy; + assert_se(tz = endswith(t_copy, tz)); + r = safe_fork("(sd-timestamp)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG_SIGKILL|FORK_WAIT, NULL); if (r < 0) { (void) munmap(shared, sizeof *shared);