summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kowalski <d.kowalski@samsung.com>2014-01-10 12:22:56 +0100
committerLubomir Rintel <lkundrak@v3.sk>2015-02-11 11:55:32 +0100
commit164b450a6aded7d148e9090f0ad1c986aeb29d52 (patch)
treea13d9c9694c592145137e1fd8e3dd340c5348b8c
parent005c68ee25735901f9ec4b3200cebebeceb992fa (diff)
[lib-fix] Add checking if strtoull returned error.
Signed-off-by: Daniel Kowalski <d.kowalski@samsung.com>
-rw-r--r--dbus/dbus-transport-kdbus.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/dbus/dbus-transport-kdbus.c b/dbus/dbus-transport-kdbus.c
index 25d033fb..d0b9a345 100644
--- a/dbus/dbus-transport-kdbus.c
+++ b/dbus/dbus-transport-kdbus.c
@@ -337,7 +337,7 @@ static struct kdbus_msg* kdbus_init_msg(const char* name, __u64 dst_id, uint64_t
*/
static int kdbus_write_msg(DBusTransportKdbus *transport, DBusMessage *message, const char* destination)
{
- struct kdbus_msg *msg;
+ struct kdbus_msg *msg = NULL;
struct kdbus_item *item;
uint64_t dst_id = KDBUS_DST_ID_BROADCAST;
const DBusString *header;
@@ -356,7 +356,14 @@ static int kdbus_write_msg(DBusTransportKdbus *transport, DBusMessage *message,
dst_id = KDBUS_DST_ID_NAME;
if((destination[0] == ':') && (destination[1] == '1') && (destination[2] == '.')) /* if name starts with ":1." it is a unique name and should be send as number */
{
+ errno = 0;
dst_id = strtoull(&destination[3], NULL, 10);
+ if(errno)
+ {
+ _dbus_verbose("error: unique name is not a number: %s (%m)\n", destination);
+ ret_size = -1;
+ goto out;
+ }
destination = NULL;
}
}
@@ -498,7 +505,8 @@ static int kdbus_write_msg(DBusTransportKdbus *transport, DBusMessage *message,
ret_size = -1;
}
out:
- free(msg);
+ if(msg)
+ free(msg);
if(use_memfd)
close(transport->memfd);