projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
eb87d3e
)
time-util: copy input string before fork()
author
Yu Watanabe
<watanabe.yu+github@gmail.com>
Tue, 8 Oct 2024 04:50:02 +0000
(13:50 +0900)
committer
Yu Watanabe
<watanabe.yu+github@gmail.com>
Tue, 8 Oct 2024 10:15:54 +0000
(19:15 +0900)
Fixes #34670.
src/basic/time-util.c
patch
|
blob
|
history
diff --git
a/src/basic/time-util.c
b/src/basic/time-util.c
index 06c465e0e40255f0a13a5d2df165f9650ae633b6..1e042b8b600ced07fa0e1181680e7904bf9fbecf 100644
(file)
--- 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);