tls: Add options for verifying the peer certificate

A file containing the trusted CA certificates needs to be
supplied via the ca_file AVOption, unless the TLS library
has got a system default file/database set up.

This doesn't check the hostname of the peer certificate with
openssl, which requires a non-trivial piece of code for
manually matching the desired hostname to the string provided
by the certificate, not provided as a library function.

That is, with openssl, this only validates that the received
certificate is signed with the right CA, but not that it is
the actual server we think we're talking to.

Verification is still disabled by default since we can't count
on a proper CA database existing at all times.

Signed-off-by: Martin Storsjö <martin@martin.st>
http: Pass options through to the nested protocol

When passing a dict to the nested protocol, it will consume
the used options from it, so a separate copy needs to be used
when reopening the connection multiple times.

Signed-off-by: Martin Storsjö <martin@martin.st>
tls: Add support for listen mode

Also add options for specifying a certificate and key, which can
be used both when operating as client and as server.

Partially based on a patch by Peter Ross.

Signed-off-by: Martin Storsjö <martin@martin.st>
rtpdec_qt: Add an accidentally removed allocation return value check

This check was mistakenly removed in 5626f994f.

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Allocate arrays with av_realloc if they will be realloced later

Pointers returned from av_malloc can't in general be passed
to av_realloc.

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Reset the entry count and allocation size variables on av_reallocp failures

When av_reallocp fails, the associated variables that keep track of
the number of elements in the array (and in some cases, the
separate number of allocated elements) need to be reset.

Not all of these might technically be needed, but it's better to
reset them if in doubt, to make sure variables don't end up
conflicting.

Signed-off-by: Martin Storsjö <martin@martin.st>
lxf: Support version 1 files

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
lxf: Support 16-channel files

Reported, analyzed and tested by Gabriel Gerard.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
pcm: support 24-bit/32-bit little-endian planar

Used by LXF.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
lxf: remove deplanarization hack

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
lxf: check the nb_streams instead of relying on padding

Remove the now unneeded stream pointer while at it.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
avframe: note that linesize is not the usable data size
lavfi: allow user-provided execute() callbacks
vqf: Make sure sample_rate is set to a valid value

This avoids divisions by zero later (and possibly assertions in
time base scaling), since an invalid rate_flag combined with an
invalid bitrate below could pass the mode combination test.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
vqf: Make sure the bitrate is in the valid range

Even if the sample rate is valid, an invalid bitrate could
pass the mode combination test below.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
avidec: Make sure a packet is large enough before reading its data

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
xwma: Avoid division by zero

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
alac: Do bounds checking of lpc_order read from the bitstream

In lpc_prediction(), we write up to array element 'lpc_order' in
an array allocated to hold 'max_samples_per_frame' elements.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
mvi: Add sanity checking for the audio frame size

This avoids a division by zero.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
riffdec: Add sanity checks for the sample rate

This avoids a division by zero for G726.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>