Commit 16355aac56 for asterisk.org
commit 16355aac568bf4e6520bfa8c93574e8f4ac0286c
Author: phoneben <3232963@gmail.com>
Date: Thu Oct 8 00:33:52 2026 +0300
format_wav.c: Reject WAV files with no audio data
format_wav.c: Reject WAV files with no audio data
A WAV file with a valid header but a zero-length data chunk is currently accepted by wav_open(), but playback later fails because there are no audio frames to read.
Reject zero-audio WAV files during wav_open() so file selection can continue to another available format instead of failing later during playback.
This was reproduced with FollowMe using a 44-byte header-only WAV. With this change, filehelper() continues to the available SLIN representation and playback proceeds normally.
AI assistance: ChatGPT assisted with the code and PR text.
Resolves: #2205
diff --git a/formats/format_wav.c b/formats/format_wav.c
index afb452b6d8..48c6d9ae08 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -329,6 +329,11 @@ static int wav_open(struct ast_filestream *s)
return -1;
}
+ if (tmp->maxlen == 0) {
+ ast_debug(2, "WAV file contains no audio data\n");
+ return -1;
+ }
+
tmp->hz = sample_rate;
return 0;
}