gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH] Fixed incorrect string argument to dbus_message_get_a


From: Andrey Mazo
Subject: [gpsd-dev] [PATCH] Fixed incorrect string argument to dbus_message_get_args().
Date: Thu, 26 Sep 2013 21:06:05 +0400

Existing behavior leads to unexpected results because it's actually
something like
static char gpsd_devname[BUFSIZ];
...
*((char**)&gpsd_devname) = "qqq";

which actually stores address of "qqq" in first several bytes of gpsd_devname[] 
(at least with gcc and clang).

DBus documentation on dbus_message_get_args() [1] states that
"The variable argument list should contain the type of the argument
followed by a pointer to where the value should be stored."
".. the returned values are constant; do not free them. They point into
the DBusMessage."

[1] 
http://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#gad8953f53ceea7de81cde792e3edd0230

Signed-off-by: Andrey Mazo <address@hidden>

diff --git a/libgps_dbus.c b/libgps_dbus.c
index b22cac8..826f12d 100644
--- a/libgps_dbus.c
+++ b/libgps_dbus.c
@@ -33,13 +33,13 @@ struct privdata_t
  */
 static struct gps_data_t *share_gpsdata;
 static DBusConnection *connection;
-static char gpsd_devname[BUFSIZ];
 
 static DBusHandlerResult handle_gps_fix(DBusMessage * message)
 {
     DBusError error;
     /* this packet format was designed before we split eph */
     double eph;
+    const char *gpsd_devname = NULL;
 
     dbus_error_init(&error);
 
-- 
1.8.1.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]