Adding our standard mutex for protecting cfs_status from multiple conflicting changes solves two things. First, it now protects cfs_status as it was changed here and secondly, it protects the global rrd_dump_buf and rrd_dump_last helper variables from incosistent access and a double free chance.
Fixes: #1559 Reported-by: Tobias Böhm <t...@robhost.de> Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com> --- data/src/status.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/data/src/status.c b/data/src/status.c index 030c003..a73fa87 100644 --- a/data/src/status.c +++ b/data/src/status.c @@ -1076,10 +1076,13 @@ void cfs_rrd_dump(GString *str) { time_t ctime; + + g_mutex_lock (&mutex); + time(&ctime); - if (rrd_dump_buf && (ctime - rrd_dump_last) < 2) { g_string_assign(str, rrd_dump_buf); + g_mutex_unlock (&mutex); return; } @@ -1108,6 +1111,8 @@ cfs_rrd_dump(GString *str) if (rrd_dump_buf) g_free(rrd_dump_buf); rrd_dump_buf = g_strdup(str->str); + + g_mutex_unlock (&mutex); } static gboolean -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel