From 40ddf32193392aee505780a0d1724f5e9e248901 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Tue, 13 Dec 2016 11:45:01 +0000 Subject: [PATCH] sd-id128: id128_write overwrites target file --- src/libelogind/sd-id128/id128-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libelogind/sd-id128/id128-util.c b/src/libelogind/sd-id128/id128-util.c index a6687b0c9..6c1c7f02d 100644 --- a/src/libelogind/sd-id128/id128-util.c +++ b/src/libelogind/sd-id128/id128-util.c @@ -187,7 +187,7 @@ int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync) { int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync) { _cleanup_close_ int fd = -1; - fd = open(p, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0444); + fd = open(p, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY|O_TRUNC, 0444); if (fd < 0) return -errno; -- 2.30.2