]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
dtls: Bring epoch choice on receive closer to the first usage.
authorJonathan Bastien-Filiatrault <joe@x2a.org>
Sat, 2 Oct 2010 21:10:13 +0000 (17:10 -0400)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 17 Feb 2011 21:55:32 +0000 (22:55 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
lib/gnutls_record.c

index c831c1872eadb335636f54beded26b760804a002..a543b230c732ee7586023067d10b31f47147e1fd 100644 (file)
@@ -932,22 +932,6 @@ _gnutls_recv_int (gnutls_session_t session, content_type_t type,
   record_parameters_st *record_params;
   record_state_st *record_state;
 
-  ret = _gnutls_epoch_get (session, EPOCH_READ_CURRENT, &record_params);
-  if (ret < 0)
-    {
-      gnutls_assert ();
-      return ret;
-    }
-
-  /* Safeguard against processing data with an incomplete cipher state. */
-  if (!record_params->initialized)
-    {
-      gnutls_assert ();
-      return GNUTLS_E_INVALID_REQUEST;
-    }
-
-  record_state = &record_params->read;
-
   if (type != GNUTLS_ALERT && (sizeofdata == 0 || data == NULL))
     {
       return GNUTLS_E_INVALID_REQUEST;
@@ -1024,6 +1008,16 @@ begin:
       return ret;
     }
 
+  ret = _gnutls_epoch_get (session, EPOCH_READ_CURRENT, &record_params);
+  if (ret < 0)
+    return gnutls_assert_val (ret);
+
+  /* Safeguard against processing data with an incomplete cipher state. */
+  if (!record_params->initialized)
+    return gnutls_assert_val (GNUTLS_E_INVALID_REQUEST);
+
+  record_state = &record_params->read;
+
 /* Here we check if the Type of the received packet is
  * ok. 
  */