1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-10 05:18:17 +03:00

time-util: copy input string before fork()

Fixes #34670.
This commit is contained in:
Yu Watanabe 2024-10-08 13:50:02 +09:00
parent eb87d3e1e9
commit 6d3012bab4

View File

@ -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);