Bug#309157: gnome-applets: stickynotes applet loses data when drive is full

Robert McQueen Robert McQueen <robot101@debian.org>, 309157@bugs.debian.org
Sun, 15 May 2005 17:15:44 +0100


This is a multi-part message in MIME format.
--------------070308080501080803010101
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

severity 309157 grave
tags 309157 + patch sarge
thanks

Marc Dequènes (Duck) wrote:
> It is sad, but having one of the many applets being able to loose data in
> an infrequent situation is not to be a RC bug, thus downgrading
> severity.

grave:
    makes the package in question unusable or mostly so, or
    causes data loss, or introduces a security hole allowing
    ^^^^^^^^^^^^^^^^
    access to the accounts of users who use the package.

I'm sorry, but I disagree, grave is appropriate because it lost all of
the data I entrusted to the applet. Furthermore, running out of disk
space is not an especially infrequent situation, and is only one of the
situations where this bug causes the applet to pointlessly clobber the
only existing copy of your notes - writes and filesystem operations can
fail for a variety of reasons and not checking the return value is
simply reckless. Given the simplicity of fixing this bug, and its
particularly irritating consequences, it's a clear candidate for fixing
as soon as possible.

> As you found where the bug lie, i would be thankful if you could you
> provide me with a patch ; i'm quite busy these days. (please keep it as
> small as possible, so i may be able to push it into sarge).

Done, attached, tagged.

> Thanks.

Regards,
Rob

--------------070308080501080803010101
Content-Type: text/x-patch;
 name="stickynotes-atomic-save.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="stickynotes-atomic-save.patch"

diff -ur gnome-applets-2.8.2~/stickynotes/stickynotes.c gnome-applets-2.8.2/stickynotes/stickynotes.c
--- gnome-applets-2.8.2~/stickynotes/stickynotes.c	2004-10-12 06:41:07.000000000 +0100
+++ gnome-applets-2.8.2/stickynotes/stickynotes.c	2005-05-15 13:55:40.918478568 +0100
@@ -19,9 +19,11 @@
 
 #include <config.h>
 #include <libxml/parser.h>
+#include <stdio.h>
 #include <stickynotes.h>
 #include <stickynotes_callbacks.h>
 #include <util.h>
+#include <unistd.h>
 
 static void response_cb (GtkWidget *dialog, gint id, gpointer data);
 
@@ -480,7 +482,15 @@
 	/* The XML file is $HOME/.gnome2/stickynotes_applet, most probably */
 	{
 		gchar *file = g_strdup_printf("%s%s", g_get_home_dir(), XML_PATH);
-		xmlSaveFormatFile(file, doc, 1);
+		gchar *tmp = g_strdup_printf("%s.tmp", file);
+
+		unlink(tmp);
+		if (xmlSaveFormatFile(tmp, doc, 1) == -1)
+			g_warning("error saving notes to %s!", tmp);
+		else
+			rename(tmp, file);
+
+		g_free(tmp);
 		g_free(file);
 	}
 	

--------------070308080501080803010101--