If we really get a situation where the underlying mtu is less than the minimum
authorMatt Caswell <matt@openssl.org>
Tue, 2 Dec 2014 00:16:55 +0000 (00:16 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 3 Dec 2014 09:35:24 +0000 (09:35 +0000)
we will support then dtls1_do_write can go into an infinite loop. This commit
fixes that.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit d3d9eef31661633f5b003a9e115c1822f79d1870)

ssl/d1_both.c

index 17a4f96240b508a27ef72861b4df73d0d3e64f9c..5acb522a38381d00559583d3910b8f24ab89d61c 100644 (file)
@@ -260,6 +260,7 @@ int dtls1_do_write(SSL *s, int type)
        {
        int ret;
        int curr_mtu;
+       int retry = 1;
        unsigned int len, frag_off, mac_size, blocksize;
 
        if(!dtls1_query_mtu(s))
@@ -365,13 +366,15 @@ int dtls1_do_write(SSL *s, int type)
                         * is fine and wait for an alert to handle the
                         * retransmit 
                         */
-                       if ( BIO_ctrl(SSL_get_wbio(s),
+                       if ( retry && BIO_ctrl(SSL_get_wbio(s),
                                BIO_CTRL_DGRAM_MTU_EXCEEDED, 0, NULL) > 0 )
                                {
                                if(!(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU))
                                        {
                                        if(!dtls1_query_mtu(s))
                                                return -1;
+                                       /* Have one more go */
+                                       retry = 0;
                                        }
                                else
                                        return -1;