From 54889c72e3469027a852d9e8ff029d659e612094 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 23 Jul 2009 12:01:03 +0200 Subject: pcm_convert: use GError for error handling Don't abort the whole MPD process when the conversion fails. This has been a denial-of-service attack vector for years. --- src/decoder_api.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/decoder_api.c') diff --git a/src/decoder_api.c b/src/decoder_api.c index 408e8005e..7f66c881e 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -225,6 +225,7 @@ decoder_data(struct decoder *decoder, struct replay_gain_info *replay_gain_info) { const char *data = _data; + GError *error = NULL; assert(dc.state == DECODE_STATE_DECODE); assert(dc.pipe != NULL); @@ -259,14 +260,15 @@ decoder_data(struct decoder *decoder, if (!audio_format_equals(&dc.in_audio_format, &dc.out_audio_format)) { data = pcm_convert(&decoder->conv_state, &dc.in_audio_format, data, length, - &dc.out_audio_format, &length); - - /* under certain circumstances, pcm_convert() may - return an empty buffer - this condition should be - investigated further, but for now, do this check as - a workaround: */ - if (data == NULL) - return DECODE_COMMAND_NONE; + &dc.out_audio_format, &length, + &error); + if (data == NULL) { + /* the PCM conversion has failed - stop + playback, since we have no better way to + bail out */ + g_warning("%s", error->message); + return DECODE_COMMAND_STOP; + } } while (length > 0) { -- cgit v1.2.3