[gnutls-devel] [PATCH] Don't match further SRTP profiles after one match has been found

Martin Storsjo martin at martin.st
Thu Dec 20 00:20:00 CET 2012


This makes SRTP profile matching more straightforward and intuitive,
when the first matching SRTP profile will be the one selected, not
the last one as before.

---

This makes the client's profile list order decide which one is chosen
if multiple profiles match. Alternatively, the server could select
the profile depending on the order of its own list, but that would be
slightly more complicated.

---

 lib/ext/srtp.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/ext/srtp.c b/lib/ext/srtp.c
index 95d7a3f..8474aa8 100644
--- a/lib/ext/srtp.c
+++ b/lib/ext/srtp.c
@@ -208,12 +208,14 @@ _gnutls_srtp_recv_params (gnutls_session_t session,
         return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
     }
 
+  priv->selected_profile = 0;
+
   while (len > 0)
     {
       DECR_LEN (data_size, 2);
       profile = _gnutls_read_uint16 (p);
 
-      for (i = 0; i < priv->profiles_size;i++)
+      for (i = 0; i < priv->profiles_size && priv->selected_profile == 0; i++)
         {
           if (priv->profiles[i] == profile)
             {
-- 
1.7.9.4




More information about the Gnutls-devel mailing list