aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodger Combs <rodger.combs@gmail.com>2017-11-13 14:46:17 -0600
committerRodger Combs <rodger.combs@gmail.com>2017-11-13 15:03:34 -0600
commita36a3d7fecdfc50691f01eef984cad6cedb6fb3a (patch)
tree55aa8efb1f0fad9b247035b222d8cc872a50ca72
parente7e7d56a850d34d710c45463607abac846972f57 (diff)
downloadffmpeg-a36a3d7fecdfc50691f01eef984cad6cedb6fb3a.tar.gz
lavf/tls_securetransport: handle incomplete reads gracefully
Signed-off-by: Aman Gupta <aman at tmm1.net>
-rw-r--r--libavformat/tls_securetransport.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/libavformat/tls_securetransport.c b/libavformat/tls_securetransport.c
index b862e0003a..dc32eb1fa8 100644
--- a/libavformat/tls_securetransport.c
+++ b/libavformat/tls_securetransport.c
@@ -54,7 +54,7 @@ static int print_tls_error(URLContext *h, int ret)
TLSContext *c = h->priv_data;
switch (ret) {
case errSSLWouldBlock:
- break;
+ return AVERROR(EAGAIN);
case errSSLXCertChainInvalid:
av_log(h, AV_LOG_ERROR, "Invalid certificate chain\n");
return AVERROR(EIO);
@@ -197,7 +197,8 @@ static OSStatus tls_read_cb(SSLConnectionRef connection, void *data, size_t *dat
{
URLContext *h = (URLContext*)connection;
TLSContext *c = h->priv_data;
- int read = ffurl_read_complete(c->tls_shared.tcp, data, *dataLength);
+ size_t requested = *dataLength;
+ int read = ffurl_read(c->tls_shared.tcp, data, requested);
if (read <= 0) {
*dataLength = 0;
switch(AVUNERROR(read)) {
@@ -214,7 +215,10 @@ static OSStatus tls_read_cb(SSLConnectionRef connection, void *data, size_t *dat
}
} else {
*dataLength = read;
- return noErr;
+ if (read < requested)
+ return errSSLWouldBlock;
+ else
+ return noErr;
}
}
@@ -326,12 +330,13 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op
if (peerTrust)
CFRelease(peerTrust);
}
- if (status == noErr)
+ if (status == noErr) {
break;
-
- av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session: %i\n", (int)status);
- ret = AVERROR(EIO);
- goto fail;
+ } else if (status != errSSLWouldBlock) {
+ av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session: %i\n", (int)status);
+ ret = AVERROR(EIO);
+ goto fail;
+ }
}
return 0;
@@ -348,6 +353,9 @@ static int map_ssl_error(OSStatus status, size_t processed)
case errSSLClosedGraceful:
case errSSLClosedNoNotify:
return 0;
+ case errSSLWouldBlock:
+ if (processed > 0)
+ return processed;
default:
return (int)status;
}