From c85b570ad78a0185f45a08e63fefc667c4f056f7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Sep 2008 17:25:08 +0200 Subject: pcm_utils: pass only one buffer size to pcm_mix() pcm_mix() might overflow the destination buffer if it is smaller than the second buffer. This is ok because the physical buffer size passed by cross_fade_apply() is always big enough, but clutters pcm_mix() with complicated length checks and contains a dangerous buffer overflow pitfall. Simplify pcm_mix()/pcm_add() and pass only the smaller buffer size; let cross_fade_apply() do the memcpy(). --- src/pcm_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pcm_utils.h') diff --git a/src/pcm_utils.h b/src/pcm_utils.h index d3dfcaf2d..59ced1331 100644 --- a/src/pcm_utils.h +++ b/src/pcm_utils.h @@ -47,8 +47,8 @@ typedef struct _ConvState { void pcm_volumeChange(char *buffer, int bufferSize, const struct audio_format *format, int volume); -void pcm_mix(char *buffer1, const char *buffer2, size_t bufferSize1, - size_t bufferSize2, const struct audio_format *format, float portion1); +void pcm_mix(char *buffer1, const char *buffer2, size_t size, + const struct audio_format *format, float portion1); size_t pcm_convertAudioFormat(const struct audio_format *inFormat, const char *inBuffer, size_t inSize, -- cgit v1.2.3