History

avfilter/af_headphone: Fix segfault when using very short streams

When the headphone filter does its processing in the time domain, the lengths of the buffers involved are determined by three parameters, only two of which are relevant here: ir_len and air_len. The former is the length (in samples) of the longest HRIR input stream and the latter is the smallest power-of-two bigger than ir_len. Using optimized functions to calculate the convolution places restrictions on the alignment of the length of the vectors whose scalar product is calculated. Therefore said length, namely ir_len, is aligned on 32; but the number of elements of the buffers used is given by air_len and for ir_len < 16 a buffer overflow happens. This commit fixes this by ensuring that air_len is always >= 32 if processing happens in the time domain.

Andreas Rheinhardt committed 6 years ago

Commit 7b74e021 parent dfd46e21 file · +3 −0Browse files

Unified · Split

libavfilter/af_headphone.c+3−0
@@ -405,6 +405,9 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) · 404 unmodified lines
405405 int i, j, k;
406406
407407 s->air_len = 1 << (32 - ff_clz(ir_len));
408+ if (s->type == TIME_DOMAIN) {
409+ s->air_len = FFALIGN(s->air_len, 32);
410+ }
408411 s->buffer_length = 1 << (32 - ff_clz(s->air_len));
409412 s->n_fft = n_fft = 1 << (32 - ff_clz(ir_len + s->size));
410413

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