From da0b93d47e01fd8c53c9d97f8352f96406ef617b Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Tue, 18 Feb 2025 18:09:54 +0100 Subject: [PATCH] avdtp_util: validate CODEC type --- src/classic/avdtp_util.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/classic/avdtp_util.c b/src/classic/avdtp_util.c index 33adea74d..55160bc9c 100644 --- a/src/classic/avdtp_util.c +++ b/src/classic/avdtp_util.c @@ -1627,6 +1627,14 @@ void avdtp_signaling_emit_delay(uint16_t avdtp_cid, uint8_t local_seid, uint16_t codec_specific_error_code_t avdtp_setup_media_codec_config_event(uint8_t *event, uint16_t size, const avdtp_stream_endpoint_t *stream_endpoint, uint16_t avdtp_cid, uint8_t reconfigure, const adtvp_media_codec_capabilities_t *media_codec, uint16_t *out_size) { codec_specific_error_code_t status; + if (stream_endpoint->sep.capabilities.media_codec.media_codec_type != media_codec->media_codec_type){ + if ((media_codec->media_codec_type >= AVDTP_CODEC_START_RFU) && (media_codec->media_codec_type < AVDTP_CODEC_NON_A2DP)){ + return CODEC_SPECIFIC_ERROR_CODE_INVALID_CODEC_TYPE; + } else { + return CODEC_SPECIFIC_ERROR_CODE_NOT_SUPPORTED_CODEC_TYPE; + } + } + switch (media_codec->media_codec_type){ case AVDTP_CODEC_SBC: status = avdtp_signaling_setup_media_codec_sbc_config_event(event, size, stream_endpoint, avdtp_cid, reconfigure,