From 4856a3c084b3a2968275cb326303decbdc259cbf Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 5 May 2023 21:19:58 +0300 Subject: [PATCH] Revert "engine: soundlib: wav: attempt to make FindNextChunk more safe" This reverts commit 78e239d883505e1ad64232812bce6ea8b726632f. --- engine/common/soundlib/snd_wav.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/engine/common/soundlib/snd_wav.c b/engine/common/soundlib/snd_wav.c index b5466439..97c268e3 100644 --- a/engine/common/soundlib/snd_wav.c +++ b/engine/common/soundlib/snd_wav.c @@ -62,14 +62,11 @@ FindNextChunk */ static void FindNextChunk( const char *name ) { - int remaining; - while( 1 ) { iff_dataPtr = iff_lastChunk; - remaining = iff_end - iff_dataPtr; - if( remaining < 8 ) + if( iff_dataPtr >= iff_end ) { // didn't find the chunk iff_dataPtr = NULL; @@ -79,24 +76,14 @@ static void FindNextChunk( const char *name ) iff_dataPtr += 4; iff_chunkLen = GetLittleLong(); - remaining -= 8; - if( iff_chunkLen < 0 ) { iff_dataPtr = NULL; return; } - if( iff_chunkLen > remaining ) - { - iff_chunkLen = remaining; - } - - remaining -= iff_chunkLen; iff_dataPtr -= 8; - iff_lastChunk = iff_dataPtr + 8 + iff_chunkLen; - if( iff_chunkLen & 1 && remaining ) - iff_chunkLen++; + iff_lastChunk = iff_dataPtr + 8 + ((iff_chunkLen + 1) & ~1); if( !Q_strncmp( (const char *)iff_dataPtr, name, 4 )) return;