Instead of copying the token thats store, return a pointer to it
along with a pointer to the token struct to free should we need to
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)
int ossl_quic_update_peer_token(SSL_CTX *ctx, BIO_ADDR *peer,
const uint8_t *token, size_t token_len);
int ossl_quic_get_peer_token(SSL_CTX *ctx, BIO_ADDR *peer,
- uint8_t **token, size_t *token_len);
+ uint8_t **token, size_t *token_len,
+ void **token_free_ptr);
__owur int ossl_quic_init(SSL *s);
void ossl_quic_deinit(SSL *s);
}
int ossl_quic_get_peer_token(SSL_CTX *ctx, BIO_ADDR *peer,
- uint8_t **token, size_t *token_len)
+ uint8_t **token, size_t *token_len,
+ void **token_free_ptr)
{
SSL_TOKEN_STORE *c = ctx->tokencache;
QUIC_TOKEN *key = NULL;
tok = NULL;
goto out;
}
- memcpy(*token, tok->token, tok->token_len);
+ *token = tok->token;
*token_len = tok->token_len;
+ *token_free_ptr = tok;
lh_QUIC_TOKEN_delete(c->cache, key);
rc = 1;
}
out:
ossl_crypto_mutex_unlock(c->mutex);
- free_quic_token(tok);
free_quic_token(key);
return rc;
}