"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libavformat/tls_openssl.c" between
libav-12.1.tar.gz and libav-12.2.tar.gz

About: libav provides cross-platform tools ("avconv") and libraries to convert, manipulate and stream a wide range of multimedia (audio and video) formats and protocols.

tls_openssl.c  (libav-12.1):tls_openssl.c  (libav-12.2)
skipping to change at line 46 skipping to change at line 46
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/err.h> #include <openssl/err.h>
static int openssl_init; static int openssl_init;
typedef struct TLSContext { typedef struct TLSContext {
const AVClass *class; const AVClass *class;
TLSShared tls_shared; TLSShared tls_shared;
SSL_CTX *ctx; SSL_CTX *ctx;
SSL *ssl; SSL *ssl;
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
BIO_METHOD* url_bio_method;
#endif
} TLSContext; } TLSContext;
#if HAVE_THREADS #if HAVE_THREADS
#include <openssl/crypto.h> #include <openssl/crypto.h>
pthread_mutex_t *openssl_mutexes; pthread_mutex_t *openssl_mutexes;
static void openssl_lock(int mode, int type, const char *file, int line) static void openssl_lock(int mode, int type, const char *file, int line)
{ {
if (mode & CRYPTO_LOCK) if (mode & CRYPTO_LOCK)
pthread_mutex_lock(&openssl_mutexes[type]); pthread_mutex_lock(&openssl_mutexes[type]);
else else
skipping to change at line 124 skipping to change at line 127
{ {
TLSContext *c = h->priv_data; TLSContext *c = h->priv_data;
if (c->ssl) { if (c->ssl) {
SSL_shutdown(c->ssl); SSL_shutdown(c->ssl);
SSL_free(c->ssl); SSL_free(c->ssl);
} }
if (c->ctx) if (c->ctx)
SSL_CTX_free(c->ctx); SSL_CTX_free(c->ctx);
if (c->tls_shared.tcp) if (c->tls_shared.tcp)
ffurl_close(c->tls_shared.tcp); ffurl_close(c->tls_shared.tcp);
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
if (c->url_bio_method)
BIO_meth_free(c->url_bio_method);
#endif
ff_openssl_deinit(); ff_openssl_deinit();
return 0; return 0;
} }
static int url_bio_create(BIO *b) static int url_bio_create(BIO *b)
{ {
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
BIO_set_init(b, 1);
BIO_set_data(b, NULL);
BIO_set_flags(b, 0);
#else
b->init = 1; b->init = 1;
b->ptr = NULL; b->ptr = NULL;
b->flags = 0; b->flags = 0;
#endif
return 1; return 1;
} }
static int url_bio_destroy(BIO *b) static int url_bio_destroy(BIO *b)
{ {
return 1; return 1;
} }
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
#define GET_BIO_DATA(x) BIO_get_data(x)
#else
#define GET_BIO_DATA(x) (x)->ptr
#endif
static int url_bio_bread(BIO *b, char *buf, int len) static int url_bio_bread(BIO *b, char *buf, int len)
{ {
URLContext *h = b->ptr; URLContext *h = GET_BIO_DATA(b);
int ret = ffurl_read(h, buf, len); int ret = ffurl_read(h, buf, len);
if (ret >= 0) if (ret >= 0)
return ret; return ret;
BIO_clear_retry_flags(b); BIO_clear_retry_flags(b);
if (ret == AVERROR_EXIT) if (ret == AVERROR_EXIT)
return 0; return 0;
return -1; return -1;
} }
static int url_bio_bwrite(BIO *b, const char *buf, int len) static int url_bio_bwrite(BIO *b, const char *buf, int len)
{ {
URLContext *h = b->ptr; URLContext *h = GET_BIO_DATA(b);
int ret = ffurl_write(h, buf, len); int ret = ffurl_write(h, buf, len);
if (ret >= 0) if (ret >= 0)
return ret; return ret;
BIO_clear_retry_flags(b); BIO_clear_retry_flags(b);
if (ret == AVERROR_EXIT) if (ret == AVERROR_EXIT)
return 0; return 0;
return -1; return -1;
} }
static long url_bio_ctrl(BIO *b, int cmd, long num, void *ptr) static long url_bio_ctrl(BIO *b, int cmd, long num, void *ptr)
skipping to change at line 179 skipping to change at line 198
return 1; return 1;
} }
return 0; return 0;
} }
static int url_bio_bputs(BIO *b, const char *str) static int url_bio_bputs(BIO *b, const char *str)
{ {
return url_bio_bwrite(b, str, strlen(str)); return url_bio_bwrite(b, str, strlen(str));
} }
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
static BIO_METHOD url_bio_method = { static BIO_METHOD url_bio_method = {
.type = BIO_TYPE_SOURCE_SINK, .type = BIO_TYPE_SOURCE_SINK,
.name = "urlprotocol bio", .name = "urlprotocol bio",
.bwrite = url_bio_bwrite, .bwrite = url_bio_bwrite,
.bread = url_bio_bread, .bread = url_bio_bread,
.bputs = url_bio_bputs, .bputs = url_bio_bputs,
.bgets = NULL, .bgets = NULL,
.ctrl = url_bio_ctrl, .ctrl = url_bio_ctrl,
.create = url_bio_create, .create = url_bio_create,
.destroy = url_bio_destroy, .destroy = url_bio_destroy,
}; };
#endif
static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op tions) static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op tions)
{ {
TLSContext *p = h->priv_data; TLSContext *p = h->priv_data;
TLSShared *c = &p->tls_shared; TLSShared *c = &p->tls_shared;
BIO *bio; BIO *bio;
int ret; int ret;
ff_openssl_init(); ff_openssl_init();
skipping to change at line 233 skipping to change at line 254
// Note, this doesn't check that the peer certificate actually matches // Note, this doesn't check that the peer certificate actually matches
// the requested hostname. // the requested hostname.
if (c->verify) if (c->verify)
SSL_CTX_set_verify(p->ctx, SSL_VERIFY_PEER, NULL); SSL_CTX_set_verify(p->ctx, SSL_VERIFY_PEER, NULL);
p->ssl = SSL_new(p->ctx); p->ssl = SSL_new(p->ctx);
if (!p->ssl) { if (!p->ssl) {
av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), NULL)) ; av_log(h, AV_LOG_ERROR, "%s\n", ERR_error_string(ERR_get_error(), NULL)) ;
ret = AVERROR(EIO); ret = AVERROR(EIO);
goto fail; goto fail;
} }
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
p->url_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK, "urlprotocol bio");
BIO_meth_set_write(p->url_bio_method, url_bio_bwrite);
BIO_meth_set_read(p->url_bio_method, url_bio_bread);
BIO_meth_set_puts(p->url_bio_method, url_bio_bputs);
BIO_meth_set_ctrl(p->url_bio_method, url_bio_ctrl);
BIO_meth_set_create(p->url_bio_method, url_bio_create);
BIO_meth_set_destroy(p->url_bio_method, url_bio_destroy);
bio = BIO_new(p->url_bio_method);
BIO_set_data(bio, c->tcp);
#else
bio = BIO_new(&url_bio_method); bio = BIO_new(&url_bio_method);
bio->ptr = c->tcp; bio->ptr = c->tcp;
#endif
SSL_set_bio(p->ssl, bio, bio); SSL_set_bio(p->ssl, bio, bio);
if (!c->listen && !c->numerichost) if (!c->listen && !c->numerichost)
SSL_set_tlsext_host_name(p->ssl, c->host); SSL_set_tlsext_host_name(p->ssl, c->host);
ret = c->listen ? SSL_accept(p->ssl) : SSL_connect(p->ssl); ret = c->listen ? SSL_accept(p->ssl) : SSL_connect(p->ssl);
if (ret == 0) { if (ret == 0) {
av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session\n"); av_log(h, AV_LOG_ERROR, "Unable to negotiate TLS/SSL session\n");
ret = AVERROR(EIO); ret = AVERROR(EIO);
goto fail; goto fail;
} else if (ret < 0) { } else if (ret < 0) {
ret = print_tls_error(h, ret); ret = print_tls_error(h, ret);
 End of changes. 11 change blocks. 
2 lines changed or deleted 35 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)