Source: mediastreamer2 Version: 1:2.16.1-2 Severity: normal Tags: patch Hi,
mediastreamer2 contains this: (src/videofilters/nowebcam.c) > #if __clang__ > #pragma clang diagnostic push > #pragma clang diagnostic ignored "-Wdeprecated-declarations" > #endif > > #define FF_INPUT_BUFFER_PADDING_SIZE 32 > > #if LIBAVCODEC_VERSION_MAJOR >= 57 > > #ifdef _MSC_VER > #pragma warning(disable : 4996) [...] > if (statbuf.st_size <= 0) { > close(fd); > ms_error("Cannot load %s", jpgpath); > return NULL; > } > jpgbuf=(uint8_t*)ms_malloc0(statbuf.st_size + > FF_INPUT_BUFFER_PADDING_SIZE); > if (jpgbuf == NULL) { > close(fd); > ms_error("Cannot allocate buffer for %s", jpgpath); > return NULL; > } This is likely to break (ie segfault somewhere) once the FFmpeg 4.0 transition starts because FFmpeg 4.0 has increased the required input buffer padding to 64 bytes. If mediastreamer2 had used the correct constant (AV_INPUT_BUFFER_PADDING_SIZE) then it would require no changes. I think the reason for writing the code this way is to support non-ffmpeg builds. Based on that, I've attached a patch which I think will be OK for both Debian and upstream. James
Description: Use AV_INPUT_BUFFER_PADDING_SIZE to determine padding size Hardcoding the value for FF_INPUT_BUFFER_PADDING_SIZE is not safe because upstream FFmpeg might change it (as they did in FFmpeg 4.0). . Instead, use FFmpeg's AV_INPUT_BUFFER_PADDING_SIZE if available and only hardcode a value if FFmpeg is disabled (in which case the value doesn't particularly matter anyway). For compatibility with older FFmpeg versions, define AV_INPUT_BUFFER_PADDING_SIZE if hasn't been defined yet. Author: James Cowgill <jcowg...@debian.org> --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/src/videofilters/ffmpegnowebcam.c +++ b/src/videofilters/ffmpegnowebcam.c @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fi #ifndef NO_FFMPEG #include "ffmpeg-priv.h" #else -#define FF_INPUT_BUFFER_PADDING_SIZE 32 +#define AV_INPUT_BUFFER_PADDING_SIZE 32 #endif #if LIBAVCODEC_VERSION_MAJOR >= 57 --- a/src/videofilters/nowebcam.c +++ b/src/videofilters/nowebcam.c @@ -34,7 +34,11 @@ Foundation, Inc., 51 Franklin Street, Fi #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif -#define FF_INPUT_BUFFER_PADDING_SIZE 32 +#ifndef NO_FFMPEG +#include "ffmpeg-priv.h" +#else +#define AV_INPUT_BUFFER_PADDING_SIZE 32 +#endif #if LIBAVCODEC_VERSION_MAJOR >= 57 @@ -130,7 +134,7 @@ static mblk_t *_ms_load_jpeg_as_yuv(cons ms_error("Cannot load %s", jpgpath); return NULL; } - jpgbuf=(uint8_t*)ms_malloc0(statbuf.st_size + FF_INPUT_BUFFER_PADDING_SIZE); + jpgbuf=(uint8_t*)ms_malloc0(statbuf.st_size + AV_INPUT_BUFFER_PADDING_SIZE); if (jpgbuf == NULL) { close(fd); ms_error("Cannot allocate buffer for %s", jpgpath); --- a/src/utils/ffmpeg-priv.h +++ b/src/utils/ffmpeg-priv.h @@ -102,6 +102,10 @@ static inline int avcodec_decode_video2( #endif #endif +#ifndef AV_INPUT_BUFFER_PADDING_SIZE + #define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE +#endif + #ifndef HAVE_FUN_avcodec_encode_video2 int avcodec_encode_video2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr); #endif
signature.asc
Description: OpenPGP digital signature