From: Jonathan Bastien-Filiatrault Date: Sat, 2 Oct 2010 21:10:13 +0000 (-0400) Subject: dtls: Bring epoch choice on receive closer to the first usage. X-Git-Tag: gnutls_2_99_0~230 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8c72985cdd7b9435bb84b90dff8b8bef604a93e6;p=thirdparty%2Fgnutls.git dtls: Bring epoch choice on receive closer to the first usage. Signed-off-by: Nikos Mavrogiannopoulos --- diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index c831c1872e..a543b230c7 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -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. */