diff mbox series

[FFmpeg-devel,3/5] avdevice/pulse_audio_dec: query actual fragment size

Message ID 20210221164659.19180-3-cus@passwd.hu
State New
Headers show
Series [FFmpeg-devel,1/5] avdevice/alsa_dec: do not set codecpar frame_size
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Marton Balint Feb. 21, 2021, 4:46 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavdevice/pulse_audio_dec.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c
index 50a3c971ae..6dea332beb 100644
--- a/libavdevice/pulse_audio_dec.c
+++ b/libavdevice/pulse_audio_dec.c
@@ -149,6 +149,7 @@  static av_cold int pulse_read_header(AVFormatContext *s)
 
     pa_buffer_attr attr = { -1 };
     pa_channel_map cmap;
+    const pa_buffer_attr *queried_attr;
 
     pa_channel_map_init_extend(&cmap, pd->channels, PA_CHANNEL_MAP_WAVEEX);
 
@@ -242,6 +243,14 @@  static av_cold int pulse_read_header(AVFormatContext *s)
         pa_threaded_mainloop_wait(pd->mainloop);
     }
 
+    /* Query actual fragment size */
+    queried_attr = pa_stream_get_buffer_attr(pd->stream);
+    if (!queried_attr || queried_attr->fragsize > INT_MAX/100) {
+        ret = AVERROR_EXTERNAL;
+        goto unlock_and_fail;
+    }
+    pd->fragment_size = queried_attr->fragsize;
+
     pa_threaded_mainloop_unlock(pd->mainloop);
 
     /* take real parameters */