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 787485 - g_tls_backend_supports_dtls () returns true when the backend doesn't
g_tls_backend_supports_dtls () returns true when the backend doesn't
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2017-09-09 19:42 UTC by David Woodhouse
Modified: 2017-09-13 16:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtlsbackend: Default to indicating no support for DTLS in GTlsBackend (1.56 KB, patch)
2017-09-11 09:02 UTC, Philip Withnall
committed Details | Review

Description David Woodhouse 2017-09-09 19:42:57 UTC
g_tls_backend_supports_dtls (GTlsBackend *backend)
{
  if (G_TLS_BACKEND_GET_INTERFACE (backend)->supports_dtls)
    return G_TLS_BACKEND_GET_INTERFACE (backend)->supports_dtls (backend);
  else if (G_IS_DUMMY_TLS_BACKEND (backend))
    return FALSE;
  else
    return TRUE;
}

Looks like the GnuTLS backend *Doesn't* support DTLS. I get a SEGV when I try to establish a DTLS conenction, because its .get_dtls_client_connection_type pointer is NULL. But g_tls_backend_supports_dtls() is returning 'TRUE' because the backend doesn't provide a ->supports_dtls method either.

*Is* there a backend that supports DTLS, and any way to actually *use* GDtlsClientConnection?
Comment 1 Philip Withnall 2017-09-11 08:57:20 UTC
(In reply to David Woodhouse from comment #0)
> g_tls_backend_supports_dtls (GTlsBackend *backend)
> {
>   if (G_TLS_BACKEND_GET_INTERFACE (backend)->supports_dtls)
>     return G_TLS_BACKEND_GET_INTERFACE (backend)->supports_dtls (backend);
>   else if (G_IS_DUMMY_TLS_BACKEND (backend))
>     return FALSE;
>   else
>     return TRUE;
> }
> 
> Looks like the GnuTLS backend *Doesn't* support DTLS. I get a SEGV when I
> try to establish a DTLS conenction, because its
> .get_dtls_client_connection_type pointer is NULL. But
> g_tls_backend_supports_dtls() is returning 'TRUE' because the backend
> doesn't provide a ->supports_dtls method either.

I can’t remember what the original reasoning for defaulting to returning TRUE from supports_dtls was, but it’s obviously wrong for backends which have never been updated to support DTLS and hence don’t have a supports_dtls vfunc.

Patch upcoming.

> *Is* there a backend that supports DTLS, and any way to actually *use*
> GDtlsClientConnection?

That’s bug #697908, which is sadly *still* waiting for review. If you want to help out with the review there, that would be much appreciated. I should be able to find time to rebase and update the patches in response to review feedback.
Comment 2 Philip Withnall 2017-09-11 09:02:33 UTC
Created attachment 359514 [details] [review]
gtlsbackend: Default to indicating no support for DTLS in GTlsBackend

I’m unsure what the original reasoning for returning TRUE by default
from supports_dtls was, but it is not backwards-compatible. If a
pre-existing GTlsBackend implementation never implements the
supports_dtls vfunc, the supports_dtls() method will magically return
TRUE rather than FALSE.

Since any backend which does implement DTLS should be implementing the
supports_dtls vfunc (and no DTLS-supporting backends have actually been
merged yet; see bug #697908), it seems safer to make this slight API
break in the name of backwards compatibility than to leave it as
returning TRUE incorrectly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Comment 3 Emmanuele Bassi (:ebassi) 2017-09-13 16:19:53 UTC
Review of attachment 359514 [details] [review]:

Signed-off-by: me
Comment 4 Philip Withnall 2017-09-13 16:39:42 UTC
Thanks for the review. Hopefully someone will take a look at bug #697908 sometime soon, before it bitrots for another year; but I won’t ask you to do that, Emmanuele. Yet.

Attachment 359514 [details] pushed as 5e55a4e - gtlsbackend: Default to indicating no support for DTLS in GTlsBackend