From 7e4bb655ad37deea1f819e3e41820532659a8f72 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 7 Mar 2025 09:38:42 +0100 Subject: [PATCH] MT#59962 Coverity Scan: Untrusted allocation size (wav_hdr) Fixes: Untrusted allocation size (TAINTED_SCALAR) tainted_data: Passing tainted expression chunk_size - 16U to wav_dummyread, which uses it as an allocation size. Change-Id: Ide2c65c1c6c440b4e5aeb610cbc813631b24a6a6 --- core/plug-in/wav/wav_hdr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/plug-in/wav/wav_hdr.c b/core/plug-in/wav/wav_hdr.c index 764c9d8b..b47bc73f 100644 --- a/core/plug-in/wav/wav_hdr.c +++ b/core/plug-in/wav/wav_hdr.c @@ -178,15 +178,17 @@ static int wav_read_header(FILE* fp, struct amci_file_desc_t* fmt_desc) fmt_desc->rate = rate; fmt_desc->channels = channels; - if( (fmt == 0x01) && (sample_size == 1)){ - ERROR("Sorry, we don't support PCM 8 bit\n"); + if( (fmt == 0x01) && (sample_size == 1)) { + ERROR("No support of PCM 8 bit!\n"); + return -1; + } else if (chunk_size < 16) { + ERROR("Chunk size is less than supported bit rate (16 bit)!\n"); return -1; } - if ((fseek(fp,chunk_size-16,SEEK_CUR) < 0) - && errno == EBADF) { + if ((fseek(fp, (chunk_size - 16), SEEK_CUR) < 0) && errno == EBADF) { is_seekable = 0; - wav_dummyread(fp,chunk_size-16); + wav_dummyread(fp, (chunk_size - 16)); } for(;;) {