From 4777e74862be35b6a31886933dbaae820c65b370 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 24 Feb 2021 13:03:24 -0800 Subject: [PATCH] sysprofd: ftruncate() when overwriting files This is really only used for proc like files which are generally a single page, but might as well start from zero. --- src/sysprofd/ipc-service-impl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sysprofd/ipc-service-impl.c b/src/sysprofd/ipc-service-impl.c index da9bf473..37229081 100644 --- a/src/sysprofd/ipc-service-impl.c +++ b/src/sysprofd/ipc-service-impl.c @@ -78,6 +78,8 @@ file_set_contents_no_backup (const gchar *path, return FALSE; } + ftruncate (fd, 0); + if (write (fd, contents, len) != len) { int errsv = errno;