summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-sysdeps.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-08-07 01:33:14 +0200
committerLennart Poettering <lennart@poettering.net>2009-10-17 00:28:31 +0200
commit1f179e0f27f656ed3c5d1ee2ac5e1bbfe26d9d94 (patch)
treef239fdaf9e72954e153d33b88e0c1fd2a04d90bf /dbus/dbus-sysdeps.h
parent2ed34f69d4400f863835c4149be4ecb82ffe1c72 (diff)
desktop-file: fix stat() race
_dbus_desktop_file_load() used to stat the desktop file before reading it, to verify its size. This is both racy and unnecessary since _dbus_file_get_contents() which it uses stats the file anyway -- does that however in a race-free fashion with fstat() instead of stat(). This patch gets rid of the redundant stat(). Also, since the desktop file change logic requires the mtime of the file it read we now export that in _dbus_file_get_contents(). This patch probably breaks Win32 builds, but afaik those are broken anyway.
Diffstat (limited to 'dbus/dbus-sysdeps.h')
-rw-r--r--dbus/dbus-sysdeps.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index 739a4546..76a9a81e 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -1,11 +1,11 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-sysdeps.h Wrappers around system/libc features (internal to D-Bus implementation)
- *
+ *
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
* Licensed under the Academic Free License version 2.1
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -15,7 +15,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -35,11 +35,11 @@
#include <string.h>
#include <stdarg.h>
-
+
/* AIX sys/poll.h does #define events reqevents, and other
* wonderousness, so must include sys/poll before declaring
* DBusPollFD
- */
+ */
#ifdef HAVE_POLL
#include <sys/poll.h>
#endif
@@ -130,9 +130,9 @@ typedef unsigned long dbus_gid_t;
*
* @todo Use for the file descriptors a struct
* - struct DBusSocket{ int d; }; -
- * instead of int to get type-safety which
+ * instead of int to get type-safety which
* will be checked by the compiler.
- *
+ *
*/
dbus_bool_t _dbus_open_tcp_socket (int *fd,
@@ -291,7 +291,7 @@ dbus_int32_t _dbus_atomic_dec (DBusAtomic *atomic);
#endif
/**
- * A portable struct pollfd wrapper.
+ * A portable struct pollfd wrapper.
*/
typedef struct
{
@@ -315,6 +315,7 @@ void _dbus_get_current_time (long *tv_sec,
dbus_bool_t _dbus_file_exists (const char *file);
dbus_bool_t _dbus_file_get_contents (DBusString *str,
const DBusString *filename,
+ unsigned long *mtime,
DBusError *error);
dbus_bool_t _dbus_string_save_to_file (const DBusString *str,
const DBusString *filename,
@@ -381,7 +382,7 @@ void _dbus_fd_set_close_on_exec (int fd);
const char* _dbus_get_tmpdir (void);
/**
- * Random numbers
+ * Random numbers
*/
void _dbus_generate_pseudorandom_bytes_buffer (char *buffer,
int n_bytes);
@@ -468,8 +469,8 @@ void _dbus_init_system_log (void);
void _dbus_log_info (const char *msg, va_list args);
void _dbus_log_security (const char *msg, va_list args);
-/* Define DBUS_VA_COPY() to do the right thing for copying va_list variables.
- * config.h may have already defined DBUS_VA_COPY as va_copy or __va_copy.
+/* Define DBUS_VA_COPY() to do the right thing for copying va_list variables.
+ * config.h may have already defined DBUS_VA_COPY as va_copy or __va_copy.
*/
#if !defined (DBUS_VA_COPY)
# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
@@ -503,7 +504,7 @@ void _dbus_log_security (const char *msg, va_list args);
_DBUS_BYTE_OF_PRIMITIVE (a, 6) == _DBUS_BYTE_OF_PRIMITIVE (b, 6) && \
_DBUS_BYTE_OF_PRIMITIVE (a, 7) == _DBUS_BYTE_OF_PRIMITIVE (b, 7))
-dbus_bool_t _dbus_get_autolaunch_address (DBusString *address,
+dbus_bool_t _dbus_get_autolaunch_address (DBusString *address,
DBusError *error);
dbus_bool_t _dbus_lookup_session_address (dbus_bool_t *supported,
@@ -526,8 +527,8 @@ dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id,
*/
dbus_bool_t _dbus_threads_init_platform_specific (void);
-dbus_bool_t _dbus_split_paths_and_append (DBusString *dirs,
- const char *suffix,
+dbus_bool_t _dbus_split_paths_and_append (DBusString *dirs,
+ const char *suffix,
DBusList **dir_list);
unsigned long _dbus_pid_for_log (void);