From 390ec2a05a33592ebde133f343d35ea8ae4ba6e6 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Thu, 11 Apr 2013 21:18:20 +0300 Subject: [PATCH] webticket: check for aborted realminfo request realminfo() callback must check for uri == NULL, i.e. request was aborted, because realminfo == NULL, i.e. no valid XML received, is a valid response to the request. This fixes a crash when the account got disconnected while the realminfo request was pending. --- src/core/sipe-webticket.c | 53 ++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/core/sipe-webticket.c b/src/core/sipe-webticket.c index 50a6142f..b50c921d 100644 --- a/src/core/sipe-webticket.c +++ b/src/core/sipe-webticket.c @@ -3,7 +3,7 @@ * * pidgin-sipe * - * Copyright (C) 2011-12 SIPE Project + * Copyright (C) 2011-2013 SIPE Project * * * This program is free software; you can redistribute it and/or modify @@ -636,28 +636,39 @@ static void realminfo(struct sipe_core_private *sipe_private, /* Only try retrieving of RealmInfo once */ webticket->retrieved_realminfo = TRUE; - if (realminfo) { - /* detect ADFS setup. See also: - * - * http://en.wikipedia.org/wiki/Active_Directory_Federation_Services - * - * NOTE: this is based on observed behaviour. - * It is unkown if this is documented somewhere... - */ - SIPE_DEBUG_INFO("realminfo: data for user %s retrieved successfully", - sipe_private->username); - - webticket->webticket_adfs_uri = sipe_xml_data(sipe_xml_child(realminfo, - "STSAuthURL")); - } + /* + * We must specifically check for abort, because + * realminfo == NULL is a valid response + */ + if (uri) { + if (realminfo) { + /* detect ADFS setup. See also: + * + * http://en.wikipedia.org/wiki/Active_Directory_Federation_Services + * + * NOTE: this is based on observed behaviour. + * It is unkown if this is documented somewhere... + */ + SIPE_DEBUG_INFO("realminfo: data for user %s retrieved successfully", + sipe_private->username); + + webticket->webticket_adfs_uri = sipe_xml_data(sipe_xml_child(realminfo, + "STSAuthURL")); + } - if (webticket->webticket_adfs_uri) - SIPE_DEBUG_INFO("realminfo: ADFS setup detected: %s", - webticket->webticket_adfs_uri); - else - SIPE_DEBUG_INFO_NOFORMAT("realminfo: no RealmInfo found or no ADFS setup detected - try direct login"); + if (webticket->webticket_adfs_uri) + SIPE_DEBUG_INFO("realminfo: ADFS setup detected: %s", + webticket->webticket_adfs_uri); + else + SIPE_DEBUG_INFO_NOFORMAT("realminfo: no RealmInfo found or no ADFS setup detected - try direct login"); - if (!fedbearer_authentication(sipe_private, wcd)) { + if (fedbearer_authentication(sipe_private, wcd)) { + /* callback data passed down the line */ + wcd = NULL; + } + } + + if (wcd) { callback_execute(sipe_private, wcd, uri, -- 2.11.4.GIT