diff options
author | Vincent Untz <vuntz@gnome.org> | 2007-09-01 14:29:28 +0000 |
---|---|---|
committer | Vincent Untz <vuntz@gnome.org> | 2007-09-01 14:29:28 +0000 |
commit | e08e4ea54ab1c90475f4a52bee98e234e7c79d1a (patch) | |
tree | 9c1d5da727509635d615e6a272f0e28a496caab4 | |
parent | c7d783c84eec8d07049ab01988e4da43559ce80f (diff) |
validate the desktop file after modifying its content, but before doing
2007-09-01 Vincent Untz <vuntz@gnome.org>
* src/install.c: (process_one_file): validate the desktop file after
modifying its content, but before doing anything else, so that we
don't unlink the original file if the created one is not valid.
Also, unlink the created file if it's not valid.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/install.c | 19 |
2 files changed, 17 insertions, 9 deletions
@@ -1,5 +1,12 @@ 2007-09-01 Vincent Untz <vuntz@gnome.org> + * src/install.c: (process_one_file): validate the desktop file after + modifying its content, but before doing anything else, so that we + don't unlink the original file if the created one is not valid. + Also, unlink the created file if it's not valid. + +2007-09-01 Vincent Untz <vuntz@gnome.org> + Don't exit(), but let the main() function do it with a proper error message. diff --git a/src/install.c b/src/install.c index dc93836..b21b337 100644 --- a/src/install.c +++ b/src/install.c @@ -191,6 +191,16 @@ process_one_file (const char *filename, g_key_file_free (kf); + /* Load and validate the file we just wrote */ + if (!desktop_file_validate (new_filename, FALSE, TRUE)) + { + g_set_error (err, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE, + _("Failed to validate the created desktop file")); + g_unlink (new_filename); + g_free (new_filename); + return; + } + if (g_chmod (new_filename, permissions) < 0) { g_set_error (err, G_FILE_ERROR, @@ -211,15 +221,6 @@ process_one_file (const char *filename, filename, g_strerror (errno)); } - /* Load and validate the file we just wrote */ - if (!desktop_file_validate (new_filename, FALSE, TRUE)) - { - g_free (new_filename); - g_set_error (err, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE, - _("Failed to validate the created desktop file")); - return; - } - if (rebuild_mime_info_cache) { rebuild_error = NULL; |