Commit 77e06aec authored by Nikos Mavrogiannopoulos's avatar Nikos Mavrogiannopoulos
Browse files

sec-mod, worker: harden TLS resumption cache against empty session data

A cached resume entry can end up with zero-length session_data, which is
not valid resumption data.

Signed-off-by: default avatarNikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
parent 9e71c1b8
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -126,7 +126,8 @@ int handle_resume_store_req(sec_mod_st *sec,

	if (req->session_id.len > GNUTLS_MAX_SESSION_ID)
		return -1;
	if (req->session_data.len > MAX_SESSION_DATA_SIZE)
	if (req->session_data.len == 0 ||
	    req->session_data.len > MAX_SESSION_DATA_SIZE)
		return -1;

	max = MAX(2 * GETRCONFIG(sec)->max_clients,
+2 −1
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ static int recv_resume_fetch_reply(worker_st *ws, int sd, gnutls_datum_t *sdata)
		return ret;
	}

	if (resp->reply != SESSION_RESUME_REPLY_MSG__RESUME__REP__OK) {
	if (resp->reply != SESSION_RESUME_REPLY_MSG__RESUME__REP__OK ||
	    resp->session_data.len == 0) {
		ret = -1;
		goto cleanup;
	}