After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 660130 - Possible loss of user data when updating mimeapps.list
Possible loss of user data when updating mimeapps.list
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-09-26 13:07 UTC by Alexander Larsson
Modified: 2011-09-30 03:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Prevent data loss in gdesktopappinfo.c (1.65 KB, patch)
2011-09-30 03:43 UTC, Matthias Clasen
committed Details | Review

Description Alexander Larsson 2011-09-26 13:07:12 UTC
gdesktopfile.c:update_mimeapps_list() Does:

  key_file = g_key_file_new ();
  load_succeeded = g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, NULL);
  if (!load_succeeded || !g_key_file_has_group (key_file, ADDED_ASSOCIATIONS_GROUP))
    {
      g_key_file_free (key_file);
      key_file = g_key_file_new ();
    }

This will lose all the data in the file if it has no added associations group, which is quite possible. We should only fail if it doesn't have any of the three standard groups.
Comment 1 Allison Karlitskaya (desrt) 2011-09-26 13:09:53 UTC
In theory, we should actually be trying to lock the file as well.
Comment 2 Matthias Clasen 2011-09-30 03:43:24 UTC
The following fix has been pushed:
5156d1b Prevent data loss in gdesktopappinfo.c
Comment 3 Matthias Clasen 2011-09-30 03:43:28 UTC
Created attachment 197841 [details] [review]
Prevent data loss in gdesktopappinfo.c

Don't loose the content of mimeapps.list when it doesn't contain
a [Added Associations] group. Pointed out by Alexander Larsson.