History

avfilter/vf_bm3d: fix heap-buffer overflows

Fixes #8262

Paul B Mahol committed 7 years ago

Commit 07490821 parent ccf4ab81 file · +4 −4Browse files

Unified · Split

libavfilter/vf_bm3d.c+4−4
@@ -706,8 +706,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 705 unmodified lines
706706 const int plane = td->plane;
707707 const int width = s->planewidth[plane];
708708 const int height = s->planeheight[plane];
709− const int block_pos_bottom = height - s->block_size;
710− const int block_pos_right = width - s->block_size;
709+ const int block_pos_bottom = FFMAX(0, height - s->block_size);
710+ const int block_pos_right = FFMAX(0, width - s->block_size);
711711 const int slice_start = (((height + block_step - 1) / block_step) * jobnr / nb_jobs) * block_step;
712712 const int slice_end = (jobnr == nb_jobs - 1) ? block_pos_bottom + block_step :
713713 (((height + block_step - 1) / block_step) * (jobnr + 1) / nb_jobs) * block_step;
@@ -796,8 +796,8 @@ static int config_input(AVFilterLink *inlink) · 82 unmodified lines
796796 for (i = 0; i < s->nb_threads; i++) {
797797 SliceContext *sc = &s->slices[i];
798798
799− sc->num = av_calloc(s->planewidth[0] * s->planeheight[0], sizeof(FFTSample));
800− sc->den = av_calloc(s->planewidth[0] * s->planeheight[0], sizeof(FFTSample));
799+ sc->num = av_calloc(FFALIGN(s->planewidth[0], s->block_size) * FFALIGN(s->planeheight[0], s->block_size), sizeof(FFTSample));
800+ sc->den = av_calloc(FFALIGN(s->planewidth[0], s->block_size) * FFALIGN(s->planeheight[0], s->block_size), sizeof(FFTSample));
801801 if (!sc->num || !sc->den)
802802 return AVERROR(ENOMEM);
803803

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