forked from abema/go-mp4
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix out-of-memory errors with mdat boxes and remove size-based checks
While patch abema#150 is able to prevent RAM exhaustion with the majority of small, specially-crafted strings, it isn'effective against strings that contain mdat boxes. A short string is able to cause RAM exhaustion by setting the mdat box size to a big number. This PR fixes the issue by replacing size-based checks with checks on the effective size of the underlying buffer, that are performed by using Seek(). In this way, an attacker may cause DoS errors if and only if he is able to upload an amount of data equal to the size of the RAM of the machine, and if there are no size checks before passing the buffer to ReadBoxStructure() or Unmarshal(). Size-based checks are performed only in case of non-uint8 slices, since it's not possible to know in advance the overall size of a generic slice.
- Loading branch information
Showing
3 changed files
with
33 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters