Skip to content

Commit

Permalink
fix: Crash with invalid v2m file
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed May 12, 2022
1 parent f42f1b4 commit fd280a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/v2mconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ static ssbase readfile(const unsigned char *inptr, const int inlen)
ssbase base;
memset(&base, 0, sizeof(base));

if (inlen < 12) return base;

base.timediv = (*((uint32_t*)(d)));
base.timediv2 = 10000*base.timediv;
base.maxtime = *((uint32_t*)(d + 4));
base.gdnum = *((uint32_t*)(d + 8));

d += 12;
base.gptr = d;

if (inlen - 12 < 10*base.gdnum) return base;
d += 10*base.gdnum;

for (int ch = 0; ch < 16; ch++)
{
ssbase::_basech &c = base.chan[ch];
Expand Down

0 comments on commit fd280a4

Please sign in to comment.