FFmpeg git repo
Go to file
Andreas Rheinhardt 8bea4a83aa avutil/bprint: Allow size == 0 in av_bprint_init_for_buffer()
The AVBPrint API guarantees that the string buffer is always
zero-terminated; in order to honour this guarantee, there
obviously must be a string buffer at all and it must have
a size >= 1. Therefore av_bprint_init_for_buffer() treats
passing a NULL buffer or size == 0 as invalid data that
leads to undefined behaviour, namely NPD in case NULL is provided
or a write to a buffer of size 0 in case size == 0.

But it would be easy to support this, namely by using the internal
buffer with AV_BPRINT_SIZE_COUNT_ONLY in case size == 0.

There is a reason to allow this: Several functions like
av_channel_(description|name) are actually wrappers
around corresponding AVBPrint functions. They accept user
provided buffers and are supposed to return the required
size of the buffer, which would allow the user to call
it once to get the required buffer size and call it once
more after having allocated the buffer.
If av_bprint_init_for_buffer() treats size == 0 as invalid,
all these users would need to check for this themselves
and basically add the same codeblock that this patch
adds to av_bprint_init_for_buffer().

This change is in line with e.g. snprintf() which also allows
the pointer to be NULL in case size is zero.

This fixes Coverity issues #1503074, #1503076 and #1503082;
all of these issues are about providing NULL to the channel-layout
functions that are wrappers around AVBPrint versions.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-10 08:53:38 +02:00
compat w32pthreads: Fix function signature mismatches for CreateThread 2023-08-04 21:51:20 +03:00
doc lavc/libx264: add mb_info option 2023-08-08 10:06:38 +02:00
ffbuild
fftools fftools/ffprobe: Use proper enum type 2023-08-08 20:20:36 +02:00
libavcodec avcodec/on2avc: use correct fft sizes 2023-08-08 18:33:21 +02:00
libavdevice avdevice/pulse_audio_common: Avoid inclusion of avcodec.h 2023-08-05 09:40:06 +02:00
libavfilter avfilter/af_vibrato: refactor code 2023-08-08 17:45:32 +02:00
libavformat avformat/matroskaenc: Don't pretend to be able to mux RV30 2023-08-10 08:37:01 +02:00
libavutil avutil/bprint: Allow size == 0 in av_bprint_init_for_buffer() 2023-08-10 08:53:38 +02:00
libpostproc
libswresample libswresample: Prevent out of bounds. 2023-08-02 17:31:13 +02:00
libswscale swscale/rgb2rgb2: rework RISC-V V shuffle_bytes_{1230,3012} 2023-07-21 22:18:02 +03:00
presets
tests fate/matroska: Add ALAC remux test 2023-08-10 08:36:47 +02:00
tools
.gitattributes
.gitignore
.mailmap
.travis.yml
Changelog lavc/libx264: add mb_info option 2023-08-08 10:06:38 +02:00
configure configure: use just the pkg-config for sndio 2023-08-07 22:31:06 +02:00
CONTRIBUTING.md
COPYING.GPLv2
COPYING.GPLv3
COPYING.LGPLv2.1
COPYING.LGPLv3
CREDITS
INSTALL.md
LICENSE.md
MAINTAINERS
Makefile
README.md
RELEASE

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 means to alter decoded audio and video through a directed graph of connected 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.