[evolution] Bug #606874 - mktemp disabled in latest glibc-2.11.90-8
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution] Bug #606874 - mktemp disabled in latest glibc-2.11.90-8
- Date: Wed, 13 Jan 2010 19:03:55 +0000 (UTC)
commit 4d114e022ca38e7aeb6cc2cc3715f7dca69c82a6
Author: Milan Crha <mcrha redhat com>
Date: Wed Jan 13 20:01:53 2010 +0100
Bug #606874 - mktemp disabled in latest glibc-2.11.90-8
composer/e-composer-autosave.c | 8 ++++++--
e-util/e-mktemp.c | 24 +++++++++++++++++++-----
2 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/composer/e-composer-autosave.c b/composer/e-composer-autosave.c
index a289866..002f6d0 100644
--- a/composer/e-composer-autosave.c
+++ b/composer/e-composer-autosave.c
@@ -91,6 +91,7 @@ static gboolean
composer_autosave_state_open (AutosaveState *state)
{
gchar *path;
+ gint fd;
if (state->file != NULL)
return TRUE;
@@ -100,13 +101,16 @@ composer_autosave_state_open (AutosaveState *state)
/* Since GIO doesn't have support for creating temporary files
* from a template (and in a given directory), we have to use
- * mktemp(), which brings a small risk of overwriting another
+ * g_mkstemp(), which brings a small risk of overwriting another
* autosave file. The risk is, however, miniscule. */
- if (mktemp (path) == NULL) {
+ fd = g_mkstemp (path);
+ if (fd == -1) {
g_free (path);
return FALSE;
}
+ close (fd);
+
/* Create the GFile */
state->file = g_file_new_for_path (path);
g_free (path);
diff --git a/e-util/e-mktemp.c b/e-util/e-mktemp.c
index 509b312..15b5668 100644
--- a/e-util/e-mktemp.c
+++ b/e-util/e-mktemp.c
@@ -167,7 +167,7 @@ gchar *
e_mktemp (const gchar *template)
{
GString *path;
- gchar *ret;
+ gint fd;
path = get_dir (TRUE);
if (!path)
@@ -179,10 +179,14 @@ e_mktemp (const gchar *template)
else
g_string_append (path, "unknown-XXXXXX");
- ret = mktemp (path->str);
- g_string_free(path, ret == NULL);
+ fd = g_mkstemp (path->str);
- return ret;
+ if (fd != -1) {
+ close (fd);
+ g_unlink (path->str);
+ }
+
+ return g_string_free (path, fd == -1);
}
gint
@@ -226,7 +230,17 @@ e_mkdtemp (const gchar *template)
#ifdef HAVE_MKDTEMP
tmpdir = mkdtemp (path->str);
#else
- tmpdir = mktemp (path->str);
+ {
+ gint fd = g_mkstemp (path->str);
+ if (fd == -1) {
+ tmpdir = NULL;
+ } else {
+ close (fd);
+ tmpdir = path->str;
+ g_unlink (tmpdir);
+ }
+ }
+
if (tmpdir) {
if (g_mkdir (tmpdir, S_IRWXU) == -1)
tmpdir = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]