History

stszin: add check for allocation error and integer overflow

Fixes (the second part of) #49.

Fabian Greffrath committed 6 years ago

Commit 79b9ff91 parent 5cc622b1 file · +7 −1Browse files

Unified · Split

frontend/mp4read.c+7−1
@@ -343,10 +343,13 @@ static int stszin(int size) · 342 unmodified lines
343 u32in();343 u32in();
344 // Number of entries344 // Number of entries
345 mp4config.frame.ents = u32in();345 mp4config.frame.ents = u32in();
346 // fixme error checking
347 // fixme: check atom size346 // fixme: check atom size
348 mp4config.frame.data = malloc(sizeof(*mp4config.frame.data)347 mp4config.frame.data = malloc(sizeof(*mp4config.frame.data)
349 * (mp4config.frame.ents + 1));348 * (mp4config.frame.ents + 1));
349
350 if (!mp4config.frame.data)
351 return ERR_FAIL;
352
350 ofs = 0;353 ofs = 0;
351 mp4config.frame.data[0] = ofs;354 mp4config.frame.data[0] = ofs;
352 for (cnt = 0; cnt < mp4config.frame.ents; cnt++)355 for (cnt = 0; cnt < mp4config.frame.ents; cnt++)
@@ -358,6 +361,9 @@ static int stszin(int size) · 5 unmodified lines
358 mp4config.frame.maxsize = fsize;361 mp4config.frame.maxsize = fsize;
359 362
360 mp4config.frame.data[cnt + 1] = ofs;363 mp4config.frame.data[cnt + 1] = ofs;
364
365 if (ofs < mp4config.frame.data[cnt])
366 return ERR_FAIL;
361 }367 }
362 368
363 return size;369 return size;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t