mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
Fix a DoS with allocating overly large silence buffers. (Identified by Luigi Auriemma (re #67)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1450 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
4a05bc9bdc
commit
33304ba118
1 changed files with 12 additions and 0 deletions
|
|
@ -38,13 +38,25 @@
|
||||||
#include "sample-util.h"
|
#include "sample-util.h"
|
||||||
#include "endianmacros.h"
|
#include "endianmacros.h"
|
||||||
|
|
||||||
|
#define PA_SILENCE_MAX (1024*1024*1)
|
||||||
|
|
||||||
pa_memblock *pa_silence_memblock_new(pa_mempool *pool, const pa_sample_spec *spec, size_t length) {
|
pa_memblock *pa_silence_memblock_new(pa_mempool *pool, const pa_sample_spec *spec, size_t length) {
|
||||||
|
size_t fs;
|
||||||
assert(pool);
|
assert(pool);
|
||||||
assert(spec);
|
assert(spec);
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
length = pa_bytes_per_second(spec)/20; /* 50 ms */
|
length = pa_bytes_per_second(spec)/20; /* 50 ms */
|
||||||
|
|
||||||
|
if (length > PA_SILENCE_MAX)
|
||||||
|
length = PA_SILENCE_MAX;
|
||||||
|
|
||||||
|
fs = pa_frame_size(spec);
|
||||||
|
length = ((PA_SILENCE_MAX+fs-1) / fs) * fs;
|
||||||
|
|
||||||
|
if (length <= 0)
|
||||||
|
length = fs;
|
||||||
|
|
||||||
return pa_silence_memblock(pa_memblock_new(pool, length), spec);
|
return pa_silence_memblock(pa_memblock_new(pool, length), spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue