Skip to content

Commit

Permalink
Fix potential infinite loop in S_PaintChannels
Browse files Browse the repository at this point in the history
when playing sounds with loop start >= end
(e.g. misc/forcefield.wav from Madfox's kaptlog.zip)
  • Loading branch information
andrei-drexler committed Jun 17, 2024
1 parent b444798 commit 3f41b0d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Quake/snd_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength)
else
info.samples = samples;

if (info.loopstart >= info.samples)
{
Con_Warning ("%s has loop start >= end\n", name);
info.loopstart = -1;

This comment has been minimized.

Copy link
@sezero

sezero Jun 17, 2024

Shouldn't we set info.samples = samples; here? Otherwise, info.samples still stays the value read from the file relying on loopstart being valid. Or am I missing something?

This comment has been minimized.

Copy link
@andrei-drexler

andrei-drexler Jun 18, 2024

Author Owner

I was getting ready to leave the house and I had missed the info.samples = 0; line in your proposed patch yesterday. Resetting info.samples to samples seems like a sensible thing to do. The code could also use a lot more validation, but for now I just wanted to fix a reported hang. Longer term, I intend to run a fuzzer on file parsing functions, I expect that to uncover a lot of bugs.

This comment has been minimized.

Copy link
@andrei-drexler

andrei-drexler Jun 18, 2024

Author Owner

Pushed 68dc185.

}

info.dataofs = data_p - wav;

return info;
Expand Down

0 comments on commit 3f41b0d

Please sign in to comment.