History

avfilter/vf_avgblur_opencl: Use AV_VIDEO_MAX_PLANES

Fixes: CID1437470 Out-of-bounds read (out of bounds read would only occur with a pixel format of more than 4 planes)

Michael Niedermayer committed 2 years ago

Commit ffba5281 parent 989e11a1 file · +5 −5Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_avgblur_opencl.c+5−5
@@ -47,8 +47,8 @@ typedef struct AverageBlurOpenCLContext { · 46 unmodified lines
4747 FilterParam luma_param;
4848 FilterParam chroma_param;
4949 FilterParam alpha_param;
50− int radius[4];
51− int power[4];
50+ int radius[AV_VIDEO_MAX_PLANES];
51+ int power[AV_VIDEO_MAX_PLANES];
5252
5353 } AverageBlurOpenCLContext;
5454
@@ -101,7 +101,7 @@ static int avgblur_opencl_make_filter_params(AVFilterLink *inlink) · 46 unmodified lines
101101 s->radiusV = s->radiusH;
102102 }
103103
104− for (i = 0; i < 4; i++) {
104+ for (i = 0; i < AV_VIDEO_MAX_PLANES; i++) {
105105 s->power[i] = 1;
106106 }
107107 return 0;
@@ -133,7 +133,7 @@ static int boxblur_opencl_make_filter_params(AVFilterLink *inlink) · 25 unmodified lines
133133 s->power[U] = s->power[V] = s->chroma_param.power;
134134 s->power[A] = s->alpha_param.power;
135135
136− for (i = 0; i < 4; i++) {
136+ for (i = 0; i < AV_VIDEO_MAX_PLANES; i++) {
137137 if (s->power[i] == 0) {
138138 s->power[i] = 1;
139139 s->radius[i] = 0;
@@ -191,7 +191,7 @@ static int avgblur_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input) · 51 unmodified lines
191191 goto fail;
192192 }
193193
194− for (p = 0; p < FF_ARRAY_ELEMS(output->data); p++) {
194+ for (p = 0; p < FFMIN(FF_ARRAY_ELEMS(output->data), AV_VIDEO_MAX_PLANES); p++) {
195195 src = (cl_mem) input->data[p];
196196 dst = (cl_mem) output->data[p];
197197 inter = (cl_mem)intermediate->data[p];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t