tls: Don't abort on non-fatal TLS alerts with gnutls

Message ID 1379801206-14691-1-git-send-email-martin@martin.st
State Committed
Commit 5055035670bd1a1eaca64bd3bc71fb07de9df2c3
Headers show

Commit Message

Martin Storsjö Sept. 21, 2013, 10:06 p.m.
---
 libavformat/tls.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Luca Barbato Sept. 21, 2013, 11:04 p.m. | #1
On 22/09/13 00:06, Martin Storsjö wrote:
> ---
>  libavformat/tls.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Looks fine, Diego will complay about using "Do not" in the subject.

> diff --git a/libavformat/tls.c b/libavformat/tls.c
> index fecf096..7fa6fc2 100644
> --- a/libavformat/tls.c
> +++ b/libavformat/tls.c
> @@ -72,7 +72,14 @@ static int do_tls_poll(URLContext *h, int ret)
>      TLSContext *c = h->priv_data;
>      struct pollfd p = { c->fd, 0, 0 };
>  #if CONFIG_GNUTLS
> -    if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) {
> +    switch (ret) {
> +    case GNUTLS_E_AGAIN:
> +    case GNUTLS_E_INTERRUPTED:
> +        break;
> +    case GNUTLS_E_WARNING_ALERT_RECEIVED:
> +        av_log(h, AV_LOG_WARNING, "%s\n", gnutls_strerror(ret));
> +        break;
> +    default:
>          av_log(h, AV_LOG_ERROR, "%s\n", gnutls_strerror(ret));
>          return AVERROR(EIO);
>      }
>

Patch

diff --git a/libavformat/tls.c b/libavformat/tls.c
index fecf096..7fa6fc2 100644
--- a/libavformat/tls.c
+++ b/libavformat/tls.c
@@ -72,7 +72,14 @@  static int do_tls_poll(URLContext *h, int ret)
     TLSContext *c = h->priv_data;
     struct pollfd p = { c->fd, 0, 0 };
 #if CONFIG_GNUTLS
-    if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) {
+    switch (ret) {
+    case GNUTLS_E_AGAIN:
+    case GNUTLS_E_INTERRUPTED:
+        break;
+    case GNUTLS_E_WARNING_ALERT_RECEIVED:
+        av_log(h, AV_LOG_WARNING, "%s\n", gnutls_strerror(ret));
+        break;
+    default:
         av_log(h, AV_LOG_ERROR, "%s\n", gnutls_strerror(ret));
         return AVERROR(EIO);
     }