From 832e1fb1749ee24583d2f7f1dc7ce7b9e68126f9 Mon Sep 17 00:00:00 2001 From: Andrey Mazo Date: Thu, 26 Sep 2013 21:06:05 +0400 Subject: Fixed incorrect string argument to dbus_message_get_args(). 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 --- libgps_dbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libgps_dbus.c') diff --git a/libgps_dbus.c b/libgps_dbus.c index b22cac84..826f12d4 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); -- cgit v1.2.1