If agent API user (in this case connman-vpnd) has not set
the memory allocation callback (context_ref pointer), then
the requst->driver pointer will be NULL and we will get
a segfault in this usage scenario:

$ connmanctl
connmanctl> vpnagent on
connmanctl> connect vpn_service
VPN Agent RequestInput vpn_service
   ....
OpenConnect Cookie? CTRL-c

Reported by Jaakko Hannikainen.
---
 src/agent.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/agent.c b/src/agent.c
index bdeb0e7..d26d8dc 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -165,12 +165,17 @@ static int send_cancel_request(struct connman_agent 
*agent,
                        struct connman_agent_request *request)
 {
        DBusMessage *message;
+       const char *interface = NULL;
 
-       DBG("send cancel req to %s %s", agent->owner, agent->path);
+       if (request && request->driver)
+               interface = request->driver->interface;
+
+       DBG("send cancel req to %s %s iface %s", agent->owner, agent->path,
+                                                               interface);
 
        message = dbus_message_new_method_call(agent->owner,
                                        agent->path,
-                                       request->driver->interface,
+                                       interface,
                                        "Cancel");
        if (!message) {
                connman_error("Couldn't allocate D-Bus message");
-- 
2.1.0

_______________________________________________
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Reply via email to