After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 730042 - Autodiscover XML can contain multiple Protocol elements
Autodiscover XML can contain multiple Protocol elements
Status: RESOLVED FIXED
Product: evolution-ews
Classification: Other
Component: Miscellaneous / EWS Core
3.12.x
Other Linux
: Normal normal
: ---
Assigned To: Evolution EWS maintainer(s)
Evolution EWS maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-05-13 01:49 UTC by mastercactapus
Modified: 2014-05-30 13:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example XML response (2.93 KB, text/xml)
2014-05-13 01:49 UTC, mastercactapus
  Details
proposed patch (1014 bytes, patch)
2014-05-13 01:50 UTC, mastercactapus
accepted-commit_now Details | Review
Bug #730042 - Autodiscover XML can contain multiple Protocol elements (3.42 KB, patch)
2014-05-19 13:23 UTC, Fabiano Fidêncio
needs-work Details | Review
Bug #730042 - Autodiscover XML can contain multiple Protocol elements (3.55 KB, patch)
2014-05-19 20:32 UTC, Fabiano Fidêncio
committed Details | Review

Description mastercactapus 2014-05-13 01:49:02 UTC
Created attachment 276423 [details]
Example XML response

Evolution reports "Failed to find ASUrl and OABUrl in autodiscover response" when trying to use an exchange account.

This happens when the first <Protocol> node does not contain
<ASUrl> in the server response.
Comment 1 mastercactapus 2014-05-13 01:50:44 UTC
Created attachment 276424 [details] [review]
proposed patch
Comment 2 Milan Crha 2014-05-15 09:38:20 UTC
Nice catch, I didn't know it can return multiple Protocol nodes.

Looking around the code, the autodiscover_parse_protocol() also needs fixing, in case the two Protocol elements contain the same searched element the previous is leaked. Also the xmlNodeGetContent() returns pointer which should be freed with xmlFree(), not with g_free() as is done now.

Nathan, could you extend the patch, please? Or I can tell Fidencio and he'll do it for you, as the found issues are not caused by your change, but are in the code for some time already.
Comment 3 Milan Crha 2014-05-15 09:39:21 UTC
Review of attachment 276424 [details] [review]:

I'm accepting the patch, the followup work will be merged and the change will be credited to you, Nathan.
Comment 4 Fabiano Fidêncio 2014-05-19 13:23:06 UTC
Okay, about the followup work:
1) I'm changing the EwsUrls::*_url to xmlChar instead of gchar.
2) I'm not doing the same changes in struct _autodiscover_data::*_url because it's used elsewhere as gchar and I don't want to change it anywhere else.
3) I'm g_strdup()'ing the EwsUrls::*_url when attributing it to struct _autodiscover_data::*_url, because I do believe the memory management will be clearer
4) autodiscover_parse_protocol() returns TRUE *only* when EwsUrls::as_url and EwsUrls:oab_url are found, but as it was before, it's considering that we can have both elements in different <Protocol> nodes.
Comment 5 Fabiano Fidêncio 2014-05-19 13:23:30 UTC
Created attachment 276771 [details] [review]
Bug #730042 - Autodiscover XML can contain multiple Protocol elements
Comment 6 Milan Crha 2014-05-19 17:43:22 UTC
Review of attachment 276771 [details] [review]:

The patch extension looks fine, thanks for it. Just add the checks below and commit both to master and stable. Thanks.

::: src/server/e-ews-connection.c
@@ +2540,3 @@
 	if (!success) {
+		xmlFree (urls->as_url);
+		xmlFree (urls->oab_url);

There is no indication they allow NULL for the argument.
Comment 7 Fabiano Fidêncio 2014-05-19 20:32:46 UTC
Created attachment 276801 [details] [review]
Bug #730042 - Autodiscover XML can contain multiple Protocol elements
Comment 8 Fabiano Fidêncio 2014-05-19 20:40:18 UTC
Pushed! Master (3.13.2+) and Stable (3.12.3+).
Comment 9 Debarshi Ray 2014-05-30 13:37:26 UTC
(In reply to comment #2)
> Nice catch, I didn't know it can return multiple Protocol nodes.

For what it is worth, all our test servers return multiple Protocol nodes but they have the OABUrl and ASUrl in the first node.
Comment 10 mastercactapus 2014-05-30 13:53:35 UTC
(In reply to comment #9)
> For what it is worth, all our test servers return multiple Protocol nodes but
> they have the OABUrl and ASUrl in the first node.

To add:
It may have something to do with: <Type>EXPR</Type> vs <Type>EXCH</Type> and which one happens to come first, but I couldn't get enough data to determine that from work (kept getting sent to the same backend)



Thanks Fabiano and Milan for the work and credit on this :)