From 71277f211903c3cbd40d33aeb37e505b1415ebb0 Mon Sep 17 00:00:00 2001 From: Steven Atkinson Date: Fri, 28 Apr 2023 17:17:28 -0700 Subject: [PATCH] Allow-list WAV chunks --- dsp/wav.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dsp/wav.cpp b/dsp/wav.cpp index c0b638d..773600b 100644 --- a/dsp/wav.cpp +++ b/dsp/wav.cpp @@ -14,17 +14,16 @@ #include "wav.h" -bool idIsJunk(char* id) +bool idIsNotJunk(char* id) { - return strncmp(id, "junk", 4) == 0 || strncmp(id, "JUNK", 4) == 0 || strncmp(id, "smpl", 4) == 0 - || strncmp(id, "LIST", 4) == 0 || strncmp(id, "bext", 4) == 0 || strncmp(id, "PAD ", 4) == 0 - || strncmp(id, "fact", 4) == 0; + return strncmp(id, "RIFF", 4) == 0 || strncmp(id, "WAVE", 4) == 0 || strncmp(id, "fmt ", 4) == 0 + || strncmp(id, "data", 4) == 0; } bool ReadChunkAndSkipJunk(std::ifstream& file, char* chunkID) { file.read(chunkID, 4); - while (idIsJunk(chunkID) && file.good()) + while (!idIsNotJunk(chunkID) && file.good()) { int junkSize; file.read(reinterpret_cast(&junkSize), 4);