From 4114f1214c65f0a142678bf98b1d8e4da43bf665 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 3 Sep 2009 15:39:57 +0200 Subject: [PATCH] Bug 594034 - Use g_mkstemp_full() when creating the replacement file Previous code used g_mkstemp(). But when using G_FILE_CREATE_REPLACE_DESTINATION, no attempt was made to ensure proper mode and flags of the created temporary file. The visible issue was that the file was always created with mode 0600 as opposed to using 0666. (The invisible issue was that O_RDWR was used instead of O_WRONLY.) --- docs/reference/glib/tmpl/glib-unused.sgml | 67 ++++++++++++++++++++++ docs/reference/glib/tmpl/macros_misc.sgml | 5 +- docs/reference/glib/tmpl/misc_utils.sgml | 7 +++ docs/reference/glib/tmpl/version.sgml | 68 ----------------------- gio/glocalfileoutputstream.c | 2 +- 5 files changed, 77 insertions(+), 72 deletions(-) diff --git a/docs/reference/glib/tmpl/glib-unused.sgml b/docs/reference/glib/tmpl/glib-unused.sgml index ca73e16e9..139c5004a 100644 --- a/docs/reference/glib/tmpl/glib-unused.sgml +++ b/docs/reference/glib/tmpl/glib-unused.sgml @@ -900,6 +900,73 @@ Turns the argument into a string literal by using the '#' stringizing operator. + + +This is the binary age passed to libtool. If +libtool means nothing to you, don't worry +about it. ;-) + + + + + + + + +@required_major: +@required_minor: +@required_micro: +@Returns: + + + +This is the interface age passed to libtool. If +libtool means nothing to you, don't worry +about it. ;-) + + + + + +The major version number of the GLib library. +(e.g. in GLib version 1.2.5 this is 1.) + + + +This variable is in the library, so represents the +GLib library you have linked against. Contrast with the +#GLIB_MAJOR_VERSION macro, which represents the major version of the +GLib headers you have included. + + + + + +The micro version number of the GLib library. +(e.g. in GLib version 1.2.5 this is 5.) + + + +This variable is in the library, so represents the GLib library you +have linked against. Contrast with the #GLIB_MICRO_VERSION macro, which +represents the micro version of the GLib headers you have included. + + + + + +The minor version number of the GLib library. +(e.g. in GLib version 1.2.5 this is 2.) + + + +This variable is in the library, so represents the +GLib library you have linked against. Contrast with the +#GLIB_MINOR_VERSION macro, which represents the minor version of the +GLib headers you have included. + + + diff --git a/docs/reference/glib/tmpl/macros_misc.sgml b/docs/reference/glib/tmpl/macros_misc.sgml index 39445574c..a8b0bcabc 100644 --- a/docs/reference/glib/tmpl/macros_misc.sgml +++ b/docs/reference/glib/tmpl/macros_misc.sgml @@ -403,7 +403,7 @@ Since: 2.14 - + Hints the compiler that the expression is likely to evaluate to a true value. The compiler may use this information for optimizations. @@ -413,10 +413,9 @@ if (G_LIKELY (random () != 1)) g_print ("not one"); +@expr: the expression @Returns: the value of @expr @Since: 2.2 - -@expr: the expression diff --git a/docs/reference/glib/tmpl/misc_utils.sgml b/docs/reference/glib/tmpl/misc_utils.sgml index 8038d8c97..9cfb65f5a 100644 --- a/docs/reference/glib/tmpl/misc_utils.sgml +++ b/docs/reference/glib/tmpl/misc_utils.sgml @@ -165,6 +165,13 @@ These are portable utility functions. @Returns: + + + + + + + diff --git a/docs/reference/glib/tmpl/version.sgml b/docs/reference/glib/tmpl/version.sgml index f46c1e1a5..b1cf0bb6f 100644 --- a/docs/reference/glib/tmpl/version.sgml +++ b/docs/reference/glib/tmpl/version.sgml @@ -19,74 +19,6 @@ typically use the features described here. - - -The major version number of the GLib library. -(e.g. in GLib version 1.2.5 this is 1.) - - - -This variable is in the library, so represents the -GLib library you have linked against. Contrast with the -#GLIB_MAJOR_VERSION macro, which represents the major version of the -GLib headers you have included. - - - - - -The minor version number of the GLib library. -(e.g. in GLib version 1.2.5 this is 2.) - - - -This variable is in the library, so represents the -GLib library you have linked against. Contrast with the -#GLIB_MINOR_VERSION macro, which represents the minor version of the -GLib headers you have included. - - - - - -The micro version number of the GLib library. -(e.g. in GLib version 1.2.5 this is 5.) - - - -This variable is in the library, so represents the GLib library you -have linked against. Contrast with the #GLIB_MICRO_VERSION macro, which -represents the micro version of the GLib headers you have included. - - - - - -This is the binary age passed to libtool. If -libtool means nothing to you, don't worry -about it. ;-) - - - - - -This is the interface age passed to libtool. If -libtool means nothing to you, don't worry -about it. ;-) - - - - - - - - -@required_major: -@required_minor: -@required_micro: -@Returns: - - The major version number of the GLib library. diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c index 79872117e..7ab8a08da 100644 --- a/gio/glocalfileoutputstream.c +++ b/gio/glocalfileoutputstream.c @@ -867,7 +867,7 @@ handle_overwrite_open (const char *filename, tmp_filename = g_build_filename (dirname, ".goutputstream-XXXXXX", NULL); g_free (dirname); - tmpfd = g_mkstemp (tmp_filename); + tmpfd = g_mkstemp_full (tmp_filename, (readable ? O_RDWR : O_WRONLY) | O_BINARY, mode); if (tmpfd == -1) { g_free (tmp_filename);