diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2001-10-30 09:10:53 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2001-10-30 09:10:53 +0000 |
commit | 9d815e661eb5b1b5063f691be6184d34e67d8ecd (patch) | |
tree | 6764c097bfe560a7b0d1ecd6142b827cc22f900e /lib | |
parent | c7f2c2739627057a47416f981fbed91444d4ecef (diff) | |
download | gnutls-9d815e661eb5b1b5063f691be6184d34e67d8ecd.tar.gz |
corrected bugs in session resuming.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gnutls_db.c | 14 | ||||
-rw-r--r-- | lib/gnutls_session.c | 17 |
2 files changed, 21 insertions, 10 deletions
diff --git a/lib/gnutls_db.c b/lib/gnutls_db.c index 2e79ceeefd..0ed1f73539 100644 --- a/lib/gnutls_db.c +++ b/lib/gnutls_db.c @@ -151,7 +151,7 @@ int _gnutls_server_register_current_session( GNUTLS_STATE state) GDBM_FILE dbf; datum key = { state->security_parameters.session_id, state->security_parameters.session_id_size }; datum content; -int ret = 0; +int ret = 0, pos; if (state->gnutls_internals.resumable==RESUME_FALSE) return GNUTLS_E_INVALID_SESSION; @@ -173,10 +173,14 @@ int ret = 0; if (content.dptr==NULL) return GNUTLS_E_MEMORY_ERROR; /* copy data */ - memcpy( content.dptr, (void*)&state->security_parameters, sizeof(SecurityParameters)); - memcpy( &content.dptr[sizeof(SecurityParameters)], &state->gnutls_key->auth_info_size, sizeof(state->gnutls_key->auth_info_size)); - memcpy( &content.dptr[sizeof(state->gnutls_key->auth_info_size)+sizeof(SecurityParameters)], - state->gnutls_key->auth_info, state->gnutls_key->auth_info_size); + pos = 0; + memcpy( &content.dptr[0], (void*)&state->security_parameters, sizeof(SecurityParameters)); + pos+=sizeof(SecurityParameters); + + memcpy( &content.dptr[pos], &state->gnutls_key->auth_info_size, sizeof(state->gnutls_key->auth_info_size)); + pos+=sizeof(state->gnutls_key->auth_info_size); + + memcpy( &content.dptr[pos], state->gnutls_key->auth_info, state->gnutls_key->auth_info_size); dbf = gdbm_open(GNUTLS_DBNAME, 0, GDBM_WRITER, 0600, NULL); if (dbf==NULL) { diff --git a/lib/gnutls_session.c b/lib/gnutls_session.c index ee6c6de7b9..d7705c2142 100644 --- a/lib/gnutls_session.c +++ b/lib/gnutls_session.c @@ -94,29 +94,36 @@ int gnutls_get_current_session_id( GNUTLS_STATE state, void* session, int *sessi * performed. **/ int gnutls_set_current_session( GNUTLS_STATE state, opaque* session, int session_size) { - int auth_info_size = session_size - sizeof(SecurityParameters); + int auth_info_size; int timestamp = time(0); SecurityParameters sp; - if (auth_info_size > sizeof(state->gnutls_key->auth_info_size)) { /* have more data */ + if ( (session_size - sizeof(SecurityParameters)) + >= sizeof(state->gnutls_key->auth_info_size)) { /* have more data */ auth_info_size = *((int*)&session[sizeof(SecurityParameters)]); + } else { + auth_info_size = 0; + gnutls_assert(); + return GNUTLS_E_DB_ERROR; } - if (session_size < sizeof(SecurityParameters)) + if (session_size < sizeof(SecurityParameters)) { + gnutls_assert(); return GNUTLS_E_UNIMPLEMENTED_FEATURE; - + } + memcpy( &sp, session, sizeof(SecurityParameters)); if ( timestamp - sp.timestamp <= state->gnutls_internals.expire_time && sp.timestamp <= timestamp) { memcpy( &state->gnutls_internals.resumed_security_parameters, &sp, sizeof(SecurityParameters)); if (auth_info_size > 0) { - state->gnutls_key->auth_info_size = auth_info_size; state->gnutls_key->auth_info = gnutls_malloc(auth_info_size); if (state->gnutls_key->auth_info==NULL) { gnutls_assert(); return GNUTLS_E_MEMORY_ERROR; } + state->gnutls_key->auth_info_size = auth_info_size; memcpy( state->gnutls_key->auth_info, &session[sizeof(SecurityParameters)+sizeof(state->gnutls_key->auth_info_size)], auth_info_size); } else { /* set to null */ state->gnutls_key->auth_info_size = 0; |