]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Corrected bugs when restoring extensions during session resumtion.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 29 Sep 2010 08:45:12 +0000 (10:45 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 29 Sep 2010 08:45:12 +0000 (10:45 +0200)
lib/ext_session_ticket.c
lib/gnutls_extensions.c

index b45053949a6d6d1e14c48a3ec88cfdccd9d7c8f5..e4ab1e2128fd47cdc3dd1b53a97d1d519b2957fa 100644 (file)
@@ -382,7 +382,7 @@ session_ticket_send_params (gnutls_session_t session,
       ret = _gnutls_ext_get_resumed_session_data( session, GNUTLS_EXTENSION_SESSION_TICKET, &epriv);
       if (ret >= 0)
        priv = epriv.ptr;
-       
+
       /* no previous data. Just advertize it */
       if (ret < 0)
         return GNUTLS_E_INT_RET_0;
@@ -417,6 +417,7 @@ session_ticket_ext_st* priv = epriv.ptr;
 int ret;
 
   BUFFER_APPEND_PFX(ps, priv->session_ticket, priv->session_ticket_len);
+  BUFFER_APPEND_NUM(ps, priv->session_ticket_enable);
 
   return 0;
 }
@@ -438,11 +439,12 @@ gnutls_datum ticket;
   BUFFER_POP_DATUM(ps, &ticket);
   priv->session_ticket = ticket.data;
   priv->session_ticket_len = ticket.size;
+  BUFFER_POP_NUM(ps, priv->session_ticket_enable);
 
   epriv.ptr = priv;
   *_priv = epriv;
   
-  ret = 0;
+  return 0;
 
 error:
   gnutls_free(priv);
@@ -603,7 +605,7 @@ _gnutls_send_new_session_ticket (gnutls_session_t session, int again)
       
       if (!priv->session_ticket_renew)
        return 0;
-      
+
       /* XXX: Temporarily set write algorithms to be used.
          _gnutls_write_connection_state_init() does this job, but it also
          triggers encryption, while NewSessionTicket should not be
@@ -663,7 +665,6 @@ _gnutls_send_new_session_ticket (gnutls_session_t session, int again)
 
       data_size = p - data;
     }
-
   ret = _gnutls_send_handshake (session, data_size ? bufel : NULL,
                                GNUTLS_HANDSHAKE_NEW_SESSION_TICKET);
 
@@ -728,7 +729,6 @@ _gnutls_recv_new_session_ticket (gnutls_session_t session)
   if (ret < 0)
     {
       gnutls_assert ();
-      gnutls_free (data);
       gnutls_free (priv->session_ticket);
       priv->session_ticket = NULL;
       return GNUTLS_E_INTERNAL_ERROR;
index 9497d143ef86b2c539a4a67496c96261dccdcd22..cfa5a03725dbbaf30b1cb128e2ef20bf18203f6e 100644 (file)
@@ -434,11 +434,10 @@ int i, ret;
 extension_priv_data_t data;
 int cur_size;
 int size_offset;
-void* total_exts_pos;
+int total_exts_pos;
 int exts = 0;
 
-  total_exts_pos = packed->data + packed->length;
-  
+  total_exts_pos = packed->length;
   BUFFER_APPEND_NUM(packed, 0);
 
   for (i = 0; i < extfunc_size; i++) 
@@ -466,7 +465,7 @@ int exts = 0;
         }
     }
 
-  _gnutls_write_uint32(exts, total_exts_pos);
+  _gnutls_write_uint32(exts, packed->data+total_exts_pos);
 
   return 0;
     
@@ -509,7 +508,7 @@ int i;
 
   for (i=0;i<MAX_EXT_TYPES;i++) 
     {
-      if (session->internals.resumed_extension_int_data[i].type == type)
+      if (session->internals.resumed_extension_int_data[i].type == type || session->internals.resumed_extension_int_data[i].set == 0)
        {
            
            if (session->internals.resumed_extension_int_data[i].set != 0)
@@ -532,6 +531,7 @@ int max_exts = 0;
 uint16_t type;
 int size_for_type, cur_pos;
 
+
   BUFFER_POP_NUM(packed, max_exts);
   for (i = 0; i < max_exts; i++) 
     {
@@ -546,14 +546,14 @@ int size_for_type, cur_pos;
          gnutls_assert();
          return GNUTLS_E_PARSING_ERROR;
        }
-    
+
       ret = unpack(packed, &data);
       if (ret < 0) 
        {
          gnutls_assert();
          return ret;
        }
-      
+
       /* verify that unpack read the correct bytes */
       cur_pos = cur_pos - packed->length;
       if (cur_pos /* read length */ != size_for_type)
@@ -561,6 +561,7 @@ int size_for_type, cur_pos;
          gnutls_assert();
          return GNUTLS_E_PARSING_ERROR;
        }
+
       _gnutls_ext_set_resumed_session_data(session, type, data);
     }