summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-01-21 12:22:58 +0000
committerMatt Caswell <matt@openssl.org>2016-02-05 20:47:36 +0000
commitce0865d8dcf4ed088a9e9ae3aa2310b7bd8c295e (patch)
tree8fb23cc3932a033d64e94b13e4ec991cb1fb6b57 /ssl
parent4b1043ef1b54b0cf27d00cff9ff9a63f2c523e63 (diff)
Add tests for DTLSv1_listen
Adds a set of tests for the newly rewritten DTLSv1_listen function. The test pokes various packets at the function and then checks the return value and the data written out to ensure it is what we would have expected. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Diffstat (limited to 'ssl')
-rw-r--r--ssl/d1_lib.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index 4aea13cc8c..b1f6ed207d 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -811,15 +811,19 @@ int DTLSv1_listen(SSL *s, BIO_ADDR *client)
s->msg_callback(1, 0, SSL3_RT_HEADER, buf,
DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg);
+
+ if ((tmpclient = BIO_ADDR_new()) == NULL) {
+ SSLerr(SSL_F_DTLSV1_LISTEN, ERR_R_MALLOC_FAILURE);
+ goto end;
+ }
+
/*
* This is unneccessary if rbio and wbio are one and the same - but
- * maybe they're not.
+ * maybe they're not. We ignore errors here - some BIOs do not
+ * support this.
*/
- if ((tmpclient = BIO_ADDR_new()) == NULL
- || BIO_dgram_get_peer(rbio, tmpclient) <= 0
- || BIO_dgram_set_peer(wbio, tmpclient) <= 0) {
- SSLerr(SSL_F_DTLSV1_LISTEN, ERR_R_INTERNAL_ERROR);
- goto end;
+ if(BIO_dgram_get_peer(rbio, tmpclient) > 0) {
+ (void)BIO_dgram_set_peer(wbio, tmpclient);
}
BIO_ADDR_free(tmpclient);
tmpclient = NULL;
@@ -868,10 +872,9 @@ int DTLSv1_listen(SSL *s, BIO_ADDR *client)
*/
ossl_statem_set_hello_verify_done(s);
- if(BIO_dgram_get_peer(rbio, client) <= 0) {
- SSLerr(SSL_F_DTLSV1_LISTEN, ERR_R_INTERNAL_ERROR);
- return -1;
- }
+ /* Some BIOs may not support this. If we fail we clear the client address */
+ if (BIO_dgram_get_peer(rbio, client) <= 0)
+ BIO_ADDR_clear(client);
ret = 1;
clearpkt = 0;