FFmpeg git repo
Go to file
Andreas Rheinhardt 010281ed23 avformat/mpegenc: Ensure packet queue stays valid
The MPEG-PS muxer uses a custom queue of custom packets. To keep track
of it, it has a pointer (named predecode_packet) to the head of the
queue and a pointer to where the next packet is to be added (it points
to the next-pointer of the last element of the queue); furthermore,
there is also a pointer that points into the queue (called premux_packet).

The exact behaviour was as follows: If premux_packet was NULL when a
packet is received, it is taken to mean that the old queue is empty and
a new queue is started. premux_packet will point to the head of said
queue and the next_packet-pointer points to its next pointer. If
predecode_packet is NULL, it will also made to point to the newly
allocated element.

But if premux_packet is NULL and predecode_packet is not, then there
will be two queues with head elements premux_packet and
predecode_packet. Yet only elements reachable from predecode_packet are
ever freed, so the premux_packet queue leaks.
Worse yet, when the predecode_packet queue will be eventually exhausted,
predecode_packet will be made to point into the other queue and when
predecode_packet will be freed, the next pointer of the preceding
element of the queue will still point to the element just freed. This
element might very well be still reachable from premux_packet which
leads to use-after-frees lateron. This happened in the tickets mentioned
below.

Fix this by never creating two queues in the first place by checking for
predecode_packet to know whether the queue is empty. If premux_packet is
NULL, then it is set to the newly allocated element of the queue.

Fixes tickets #6887, #8188 and #8266.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit cfce16449c)
2021-10-19 19:05:16 -03:00
compat compat: remove in-tree NVidia headers 2018-02-27 16:22:12 +01:00
doc Update for 4.1.8 2021-10-06 13:43:40 +02:00
ffbuild
fftools fftools/ffmpeg: Fix integer overflow in duration computation in seek_to_start() 2020-07-03 12:10:23 +02:00
libavcodec avcodec/apedec: Use 64bit to avoid overflow 2021-10-16 21:19:24 +02:00
libavdevice Bump minor versions for branching 4.1 2018-11-02 00:15:32 +01:00
libavfilter avfilter/scale_npp: fix non-aligned output frame dimensions 2021-10-07 18:31:41 +02:00
libavformat avformat/mpegenc: Ensure packet queue stays valid 2021-10-19 19:05:16 -03:00
libavresample avresample: remove deprecated attribute from the AVAudioResampleContext struct 2018-01-09 10:56:53 -03:00
libavutil avutil/common: Add FF_PTR_ADD() 2021-09-09 13:53:29 +02:00
libpostproc postproc/postprocess_template: remove FF_REG_sp from clobber list 2019-01-21 07:53:26 +01:00
libswresample Bump minor versions for branching 4.1 2018-11-02 00:15:32 +01:00
libswscale swscale/alphablend: Fix slice handling 2021-10-06 12:06:15 +02:00
presets
tests avcodec/fitsdec: Use lrint() 2020-01-06 15:03:15 +01:00
tools tools/cws2fws: Check read() for failure 2021-09-09 13:54:52 +02:00
.gitattributes
.gitignore Remove the ffserver program 2018-01-06 18:31:37 +00:00
.travis.yml
CONTRIBUTING.md
COPYING.GPLv2
COPYING.GPLv3
COPYING.LGPLv2.1
COPYING.LGPLv3
CREDITS
Changelog Changelog: update 2021-10-17 19:42:14 +02:00
INSTALL.md
LICENSE.md
MAINTAINERS MAINTAINERS: remove myself as hls demuxer maintainer 2018-10-16 01:18:00 +03:00
Makefile avcodec/parser: move parsers list and related API to its own file 2018-07-21 16:08:29 -03:00
README.md Remove the ffserver program 2018-01-06 18:31:37 +00:00
RELEASE Update for 4.1.8 2021-10-06 13:43:40 +02:00
RELEASE_NOTES Update missed irc links 2021-09-09 13:54:52 +02:00
configure configure: update copyright year 2021-10-16 21:19:24 +02:00

README.md

FFmpeg README

FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata.

Libraries

  • libavcodec provides implementation of a wider range of codecs.
  • libavformat implements streaming protocols, container formats and basic I/O access.
  • libavutil includes hashers, decompressors and miscellaneous utility functions.
  • libavfilter provides a mean to alter decoded Audio and Video through chain of filters.
  • libavdevice provides an abstraction to access capture and playback devices.
  • libswresample implements audio mixing and resampling routines.
  • libswscale implements color conversion and scaling routines.

Tools

  • ffmpeg is a command line toolbox to manipulate, convert and stream multimedia content.
  • ffplay is a minimalistic multimedia player.
  • ffprobe is a simple analysis tool to inspect multimedia content.
  • Additional small tools such as aviocat, ismindex and qt-faststart.

Documentation

The offline documentation is available in the doc/ directory.

The online documentation is available in the main website and in the wiki.

Examples

Coding examples are available in the doc/examples directory.

License

FFmpeg codebase is mainly LGPL-licensed with optional components licensed under GPL. Please refer to the LICENSE file for detailed information.

Contributing

Patches should be submitted to the ffmpeg-devel mailing list using git format-patch or git send-email. Github pull requests should be avoided because they are not part of our review process and will be ignored.