From 5e1f06ce52527e2e06afc513e76138a638edf258 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Wed, 25 May 2016 10:57:00 -0600 Subject: [PATCH] sanity checks on wolfSSL_dtls_get_peer arguments --- src/ssl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ssl.c b/src/ssl.c index 6f6c4f15f..01cea2bde 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -517,8 +517,13 @@ int wolfSSL_dtls_set_peer(WOLFSSL* ssl, void* peer, unsigned int peerSz) int wolfSSL_dtls_get_peer(WOLFSSL* ssl, void* peer, unsigned int* peerSz) { #ifdef WOLFSSL_DTLS + if (ssl == NULL) { + return SSL_FAILURE; + } + if (peer != NULL && peerSz != NULL - && *peerSz >= ssl->buffers.dtlsCtx.peer.sz) { + && *peerSz >= ssl->buffers.dtlsCtx.peer.sz + && ssl->buffers.dtlsCtx.peer.sa != NULL) { *peerSz = ssl->buffers.dtlsCtx.peer.sz; XMEMCPY(peer, ssl->buffers.dtlsCtx.peer.sa, *peerSz); return SSL_SUCCESS;