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
343343 u32in();
344344 // Number of entries
345345 mp4config.frame.ents = u32in();
346− // fixme error checking
347346 // fixme: check atom size
348347 mp4config.frame.data = malloc(sizeof(*mp4config.frame.data)
349348 * (mp4config.frame.ents + 1));
349+
350+ if (!mp4config.frame.data)
351+ return ERR_FAIL;
352+
350353 ofs = 0;
351354 mp4config.frame.data[0] = ofs;
352355 for (cnt = 0; cnt < mp4config.frame.ents; cnt++)
@@ -358,6 +361,9 @@ static int stszin(int size) · 5 unmodified lines
358361 mp4config.frame.maxsize = fsize;
359362
360363 mp4config.frame.data[cnt + 1] = ofs;
364+
365+ if (ofs < mp4config.frame.data[cnt])
366+ return ERR_FAIL;
361367 }
362368
363369 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