Skip to content

Commit

Permalink
Exhumed: Always perform a range check on a sequence's length.
Browse files Browse the repository at this point in the history
Too many of these are not correct and prone to overflows so ignoring this is not good.
  • Loading branch information
coelckers committed Nov 5, 2023
1 parent 40265e6 commit c039882
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions source/games/exhumed/src/sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ void seq_PlotArrowSequence(const int nSprite, const FName seqFile, const int16_t
//
//---------------------------------------------------------------------------

void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqIndex, const int16_t frameIndex, const int16_t nFlags)
void seq_PlotSequence(const int nSprite, const FName seqFile, const int seqIndex, int frameIndex, const int nFlags)
{
tspritetype* pTSprite = mytspriteArray->get(nSprite);
const auto pPlayer = getPlayer(nLocalPlayer);
Expand All @@ -464,7 +464,11 @@ void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqI
}

const auto fileSeqs = getFileSeqs(seqFile);
const auto& seqFrame = fileSeqs->Data(seqIndex + seqOffset)->frames[frameIndex];
if (seqIndex + seqOffset > fileSeqs->SSize()) return;
const auto& sequence = fileSeqs->Data(seqIndex + seqOffset);
if (sequence->frames.SSize() <= frameIndex) frameIndex = sequence->frames.SSize() - 1;

const auto& seqFrame = sequence->frames[frameIndex];
const auto chunkCount = seqFrame.chunks.Size();

const auto nShade = pTSprite->shade - (100 * !!(fileSeqs->Data(seqIndex)->frames[frameIndex].flags & 4));
Expand Down
2 changes: 1 addition & 1 deletion source/games/exhumed/src/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extern int16_t nPilotLightCount;

void seq_LoadSequences();
void seq_DrawGunSequence(const SeqFrame& seqFrame, double xPos, double yPos, int nShade, int nPal, DAngle nAngle, double nAlpha, int nStat = 0);
void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqIndex, const int16_t frameIndex, const int16_t nFlags);
void seq_PlotSequence(const int nSprite, const FName seqFile, const int seqIndex, int frameIndex, const int nFlags);
void seq_PlotArrowSequence(const int nSprite, const FName seqFile, const int16_t seqIndex, const int frameIndex);
void seq_DrawPilotLightSeq(double xPos, double yPos, double nAngle);

Expand Down

0 comments on commit c039882

Please sign in to comment.