/[packages]/updates/8/ffmpeg/current/SOURCES/CVE-2020-22038.patch
ViewVC logotype

Contents of /updates/8/ffmpeg/current/SOURCES/CVE-2020-22038.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1752890 - (show annotations) (download)
Mon Oct 25 13:21:11 2021 UTC (2 years, 5 months ago) by ns80
File size: 3297 byte(s)
- SILENT: fix patch for CVE-2020-22038

1 From: Andriy Gelman <andriy.gelman@gmail.com>
2 Date: Sun, 2 Aug 2020 18:31:22 +0000 (-0400)
3 Subject: avcodec/v4l2_m2m: adapt to call close() on init fail
4 X-Git-Tag: n4.4~3167
5 X-Git-Url: https://git.videolan.org/?p=ffmpeg.git;a=commitdiff_plain;h=7c32e9cf93b712f8463573a59ed4e98fd10fa013
6
7 avcodec/v4l2_m2m: adapt to call close() on init fail
8
9 This fixes several mem leaks when init of encoder/decoder failed.
10
11 Fixes ticket #8285
12
13 Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
14 ---
15
16 diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
17 index d8d872ea09..944c1a2823 100644
18 --- a/libavcodec/v4l2_m2m.c
19 +++ b/libavcodec/v4l2_m2m.c
20 @@ -330,6 +330,7 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context)
21 sem_destroy(&s->refsync);
22
23 close(s->fd);
24 + av_packet_unref(&s->buf_pkt);
25
26 av_free(s);
27 }
28 @@ -339,6 +340,10 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
29 V4L2m2mContext *s = priv->context;
30 int ret;
31
32 + if (!s)
33 + return 0;
34 +
35 + if (s->fd >= 0) {
36 ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF);
37 if (ret)
38 av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name);
39 @@ -346,6 +351,7 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
40 ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF);
41 if (ret)
42 av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name);
43 + }
44
45 ff_v4l2_context_release(&s->output);
46
47 diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
48 index b038efed9c..ab07c0a24a 100644
49 --- a/libavcodec/v4l2_m2m_dec.c
50 +++ b/libavcodec/v4l2_m2m_dec.c
51 @@ -205,9 +205,6 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
52 ret = ff_v4l2_m2m_codec_init(priv);
53 if (ret) {
54 av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");
55 - s->self_ref = NULL;
56 - av_buffer_unref(&priv->context_ref);
57 -
58 return ret;
59 }
60
61 @@ -216,10 +213,7 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
62
63 static av_cold int v4l2_decode_close(AVCodecContext *avctx)
64 {
65 - V4L2m2mPriv *priv = avctx->priv_data;
66 - V4L2m2mContext *s = priv->context;
67 - av_packet_unref(&s->buf_pkt);
68 - return ff_v4l2_m2m_codec_end(priv);
69 + return ff_v4l2_m2m_codec_end(avctx->priv_data);
70 }
71
72 #define OFFSET(x) offsetof(V4L2m2mPriv, x)
73 @@ -254,7 +248,7 @@ static const AVOption options[] = {
74 .close = v4l2_decode_close, \
75 .bsfs = bsf_name, \
76 .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
77 - .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, \
78 + .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \
79 .wrapper_name = "v4l2m2m", \
80 }
81
82 diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
83 index 56df4286ad..af0ed1e306 100644
84 --- a/libavcodec/v4l2_m2m_enc.c
85 +++ b/libavcodec/v4l2_m2m_enc.c
86 @@ -429,6 +429,7 @@ static const AVCodecDefault v4l2_m2m_defaults[] = {
87 .close = v4l2_encode_close, \
88 .defaults = v4l2_m2m_defaults, \
89 .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \
90 + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \
91 .wrapper_name = "v4l2m2m", \
92 }
93

  ViewVC Help
Powered by ViewVC 1.1.30