Don't crash when a session callback returns NULL.

4aa154e08f changed the code to assume that
a session callback will zero the |copy| out-arg before returning NULL.
In practice this doesn't always happen and we should be robust against
it.

Change-Id: I0fd14969df836e0fa4f68ded8648fea8094ff9d7
Reviewed-on: https://boringssl-review.googlesource.com/10640
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
Adam Langley 2016-08-26 09:22:56 -07:00 committed by CQ bot account: commit-bot@chromium.org
parent 07e7806177
commit 81f433540e

View File

@ -633,6 +633,10 @@ static enum ssl_session_result_t ssl_lookup_session(
session = ssl->initial_ctx->get_session_cb(ssl, (uint8_t *)session_id,
session_id_len, &copy);
if (session == NULL) {
return ssl_session_success;
}
if (session == SSL_magic_pending_session_ptr()) {
return ssl_session_retry;
}
@ -646,8 +650,7 @@ static enum ssl_session_result_t ssl_lookup_session(
}
/* Add the externally cached session to the internal cache if necessary. */
if (session != NULL &&
!(ssl->initial_ctx->session_cache_mode &
if (!(ssl->initial_ctx->session_cache_mode &
SSL_SESS_CACHE_NO_INTERNAL_STORE)) {
SSL_CTX_add_session(ssl->initial_ctx, session);
}