If the user cancelled the agent request, then we might
have NULL reply in the input handler. If we try to pass
this kind of reply to dbus library, it will normally
just abort. So catch this and do not pass NULL message
to dbus_message_get_type().

This affects openconnect, l2tp and pptp input handlers.
---
 vpn/plugins/l2tp.c        | 5 +++--
 vpn/plugins/openconnect.c | 2 +-
 vpn/plugins/pptp.c        | 5 +++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/vpn/plugins/l2tp.c b/vpn/plugins/l2tp.c
index 22f9dcf..372e2ed 100644
--- a/vpn/plugins/l2tp.c
+++ b/vpn/plugins/l2tp.c
@@ -497,8 +497,9 @@ static void request_input_reply(DBusMessage *reply, void 
*user_data)
 
        DBG("provider %p", l2tp_reply->provider);
 
-       if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
-               error = dbus_message_get_error_name(reply);
+       if (!reply || dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
+               if (reply)
+                       error = dbus_message_get_error_name(reply);
                goto done;
        }
 
diff --git a/vpn/plugins/openconnect.c b/vpn/plugins/openconnect.c
index 5feaed9..87679bf 100644
--- a/vpn/plugins/openconnect.c
+++ b/vpn/plugins/openconnect.c
@@ -315,7 +315,7 @@ static void request_input_cookie_reply(DBusMessage *reply, 
void *user_data)
 
        DBG("provider %p", data->provider);
 
-       if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
+       if (!reply || dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
                goto err;
 
        if (!vpn_agent_check_reply_has_dict(reply))
diff --git a/vpn/plugins/pptp.c b/vpn/plugins/pptp.c
index 9f2a214..90fd24c 100644
--- a/vpn/plugins/pptp.c
+++ b/vpn/plugins/pptp.c
@@ -289,8 +289,9 @@ static void request_input_reply(DBusMessage *reply, void 
*user_data)
 
        DBG("provider %p", pptp_reply->provider);
 
-       if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
-               error = dbus_message_get_error_name(reply);
+       if (!reply || dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
+               if (reply)
+                       error = dbus_message_get_error_name(reply);
                goto done;
        }
 
-- 
2.1.0

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to