[sysprof] sysprofd: ftruncate() when overwriting files
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] sysprofd: ftruncate() when overwriting files
- Date: Wed, 24 Feb 2021 22:01:13 +0000 (UTC)
commit 4777e74862be35b6a31886933dbaae820c65b370
Author: Christian Hergert <chergert redhat com>
Date: Wed Feb 24 13:03:24 2021 -0800
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 da9bf47..3722908 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]