diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-02-01 20:22:09 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-02-01 20:22:09 +0100 |
commit | 4e95b60f8e2df2e86e296f55d96343cbab5806f5 (patch) | |
tree | 3ba5e47e2268347425685a8877417b2cee27140f /lib/gnutls_db.c | |
parent | f218562ece1267d0e0e3f36415463e385b5d266f (diff) | |
download | gnutls-4e95b60f8e2df2e86e296f55d96343cbab5806f5.tar.gz |
simplified DB storing
Diffstat (limited to 'lib/gnutls_db.c')
-rw-r--r-- | lib/gnutls_db.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/lib/gnutls_db.c b/lib/gnutls_db.c index 03bc5a0806..471f920670 100644 --- a/lib/gnutls_db.c +++ b/lib/gnutls_db.c @@ -215,8 +215,7 @@ store_session (gnutls_session_t session, } /* if we can't read why bother writing? */ - if (session->internals.db_store_func != NULL) - ret = session->internals.db_store_func (session->internals.db_ptr, + ret = session->internals.db_store_func (session->internals.db_ptr, session_id, session_data); return (ret == 0 ? ret : GNUTLS_E_DB_ERROR); @@ -258,26 +257,6 @@ _gnutls_server_register_current_session (gnutls_session_t session) return ret; } -/* Retrieves session data from the db backend. - */ -static gnutls_datum_t -retrieve_session (gnutls_session_t session, gnutls_datum_t session_id) -{ - gnutls_datum_t ret = { NULL, 0 }; - - if (session_id.data == NULL || session_id.size == 0) - { - gnutls_assert (); - return ret; - } - - if (session->internals.db_retrieve_func != NULL) - ret = session->internals.db_retrieve_func (session->internals.db_ptr, - session_id); - - return ret; -} - int _gnutls_server_restore_session (gnutls_session_t session, uint8_t * session_id, int session_id_size) @@ -286,6 +265,12 @@ _gnutls_server_restore_session (gnutls_session_t session, gnutls_datum_t key; int ret; + if (session_id == NULL || session_id_size == 0) + { + gnutls_assert (); + return GNUTLS_E_INVALID_REQUEST; + } + if (session->internals.premaster_set != 0) { /* hack for CISCO's DTLS-0.9 */ if (session_id_size == session->internals.resumed_security_parameters.session_id_size && @@ -302,7 +287,8 @@ _gnutls_server_restore_session (gnutls_session_t session, return GNUTLS_E_INVALID_SESSION; } - data = retrieve_session (session, key); + data = session->internals.db_retrieve_func (session->internals.db_ptr, + key); if (data.data == NULL) { @@ -344,7 +330,7 @@ gnutls_db_remove_session (gnutls_session_t session) session_id.data = session->security_parameters.session_id; session_id.size = session->security_parameters.session_id_size; - if (session->internals.db_remove_func != NULL) + if (session->internals.db_remove_func == NULL) { gnutls_assert (); return /* GNUTLS_E_DB_ERROR */; @@ -357,11 +343,8 @@ gnutls_db_remove_session (gnutls_session_t session) } /* if we can't read why bother writing? */ - if (session->internals.db_remove_func != NULL) - { - ret = session->internals.db_remove_func (session->internals.db_ptr, + ret = session->internals.db_remove_func (session->internals.db_ptr, session_id); - if (ret != 0) - gnutls_assert (); - } + if (ret != 0) + gnutls_assert (); } |