Commit Graph

206 Commits

Author SHA1 Message Date
Tom Finegan
1a6dc4f210 mkvparser: Cues::PreloadCuePoint now returns bool.
Check allocations and fail appropriately.

Change-Id: Ie16d258a47e46b5e15c5c6275ea83ebead8b0f49
2015-08-24 16:20:13 -07:00
James Zern
064f2eed62 Segment::PreloadCluster(): return a bool status
BUG=23430793

Change-Id: I10aab67e94961868be806ee7ee9df550a5187e5a
2015-08-22 11:02:55 -07:00
James Zern
3778408b2a Segment::AppendCluster(): return a bool status
BUG=23430793

Change-Id: I6072234bfe211153ad143ccf7a3c6bbfa8cd166e
2015-08-22 11:01:47 -07:00
James Zern
e86d046c07 mkvparser: check Cluster::Create() return
BUG=23430793

Change-Id: Ie932dd2ee82d41368616999ab75ba3b213008642
2015-08-22 10:47:03 -07:00
James Zern
f9885b5882 mkvparser: check allocations
some unchecked new's are left in a few void functions, they'll be
addressed in a separate commit

BUG=23430793

Change-Id: I4953e70f4e7b0401a293c6b87c02445960e9ff9e
2015-08-22 10:47:03 -07:00
James Zern
21ee398281 mkvparser: Segment::Load fail w/missing info/tracks
convert asserts to error returns

BUG=23430793

Change-Id: Ifbfb5a2e7cd41344acc9c8d7afdf183b28dc2cd2
2015-08-22 10:47:03 -07:00
James Zern
08fb6546e8 Merge changes I264e68b2,Ife6190a4,Ibf37245f,I06efadb5,I88b5dfec, ...
* changes:
  mkvparser/Cluster: convert asserts to failure returns
  mkvparser/Tracks: convert asserts to failure returns
  mkvparser/Track: convert asserts to failure returns
  mkvparser/ContentEncoding: convert asserts to failure returns
  mkvparser/Cues: convert asserts to failure returns
  mkvparser/SeekHead: convert asserts to failure returns
  mkvparser/Segment: convert asserts to failure returns
2015-08-22 05:52:07 +00:00
James Zern
c8960955db mkvparser/Cluster: convert asserts to failure returns
Change-Id: I264e68b24eeb0f719a9d60b4cb0454e38110dd39
2015-08-21 22:49:57 -07:00
James Zern
680b4bfd3d mkvparser/Tracks: convert asserts to failure returns
BUG=23431751

Change-Id: Ife6190a4bcd4ab949165f17fd0b6c26a058a661b
2015-08-21 22:49:57 -07:00
James Zern
5889e6c18b mkvparser/Track: convert asserts to failure returns
Change-Id: Ibf37245f74e019c788b3f4121082956aa209430a
2015-08-21 22:49:57 -07:00
James Zern
5135c4cd74 mkvparser/ContentEncoding: convert asserts to failure returns
Change-Id: I06efadb5242135b095ad4cdefceef0e1c42c79b9
2015-08-21 22:49:57 -07:00
James Zern
b0e4f32011 mkvparser/Cues: convert asserts to failure returns
Change-Id: I88b5dfecfd03fec7f5808959ec6f640bff838d7a
2015-08-21 22:45:02 -07:00
James Zern
13ccc7f089 mkvparser/UnserializeInt: fix sign flip
with -funsigned-char the sign will be flipped, e.g., -128 -> 128, use an
explicit signed char.

additionally drop the misguided range check; this is meant as a data
size limit not one for the big-endian encoded ints

Change-Id: Ia10ef811d16acd09cbcd3d95856d9c460c9b7f16
2015-08-21 22:35:20 -07:00
James Zern
db3f9bbd79 mkvparser/SeekHead: convert asserts to failure returns
Change-Id: Ic2c83e4eb246fd4c1fc63fe16298f0dc78801912
2015-08-21 19:47:34 -07:00
James Zern
8de3654fdb mkvparser/Segment: convert asserts to failure returns
Change-Id: I7ccfd5be5e7438561edacb06bc8e6256aa6e0369
2015-08-21 19:46:15 -07:00
James Zern
fa2aa7da2d SeekHead::Parse(): fix assertion failure
replace assertions with failure returns

BUG=23430787
BUG=23431751

Change-Id: I22f000388cf040d064ba898c5de3658b56a3dfea
2015-08-21 18:12:08 -07:00
Tom Finegan
c56ee29254 mkvparser: Remove some asserts.
Remove asserts in sections recently updated to do error checking, and
replace some additional nearby asserts with error checks.

Change-Id: Ia8b60824736a7a821bbca3f2bfef5de4bb584c2d
2015-08-21 13:06:09 -07:00
Tom Finegan
42fe2cd755 mkvparser: Remove some asserts from SegmentInfo::Parse.
Just return errors.

Change-Id: Ic3510db9c298e12cbe2a40fe09344a1c8e1e4ca8
2015-08-21 12:10:38 -07:00
Tom Finegan
8bccd9c306 Merge "mkvparser: avoid rollover in UnserializeInt()." 2015-08-21 18:47:16 +00:00
Tom Finegan
7a2fa0daf3 mkvparser: avoid rollover in UnserializeInt().
- Not strictly rollover-- avoid exceeding max 64 EBML (2^26 - 2).
- Tidy up the function.

BUG=23321923

Change-Id: I172c75064c189ed0fcf224145d016fca421f60c6
2015-08-21 11:24:30 -07:00
Tom Finegan
44f5ce64b1 mkvparser: Disallow durations in seconds greater than LONG_LONG_MAX.
libwebm cannot handle a duration in seconds greater than LONG_LONG_MAX
because it stores the values in long long variables.

BUG=23321923

Change-Id: Idb73f04a73e35829ae34386ea6c388fd355dd102
2015-08-21 10:54:27 -07:00
Tom Finegan
b521e3030e Merge "mkvparser: Segment::ParseHeaders() avoid rollover and bad int sizes." 2015-08-20 16:59:29 +00:00
Tom Finegan
7680e2a76b mkvparser: Check for errors in Match().
Confirm asserted conditions are as expected in all build
configurations, and avoid rolling over pos in obvious places.

BUG=23225325

Change-Id: I8af3192283788fd4a4b5b8ba4ad94abeab7feff2
2015-08-19 21:46:32 -07:00
Tom Finegan
39a315f8c1 mkvparser: Segment::ParseHeaders() avoid rollover and bad int sizes.
BUG=23226908

Change-Id: I177fc75684daa3c0282b63ec270d095251a70881
2015-08-19 21:23:21 -07:00
Tom Finegan
f250aceeaa mkvparser: Handle invalid lengths and rollover in ParseElementHeader().
BUG=23224239

Change-Id: I597054dc552b54f99a6716fb8f1b0f2480f2a29b
2015-08-19 12:34:54 -07:00
Tom Finegan
cd96a76985 mkvparser: Avoid rollover/truncation in UnserializeString().
Change-Id: I355d00b59ec1b7645ae5b4010e292215b5da3a17
2015-08-17 15:35:44 -07:00
Tom Finegan
986b64b8c0 mkvparser: Add error checking in Block::Parse.
Instead of relying solely on asserts, which compile away to
nothing in downstream projects using libwebm for parsing webm
input streams, actually check for the conditions being asserted,
and return errors when appropriate.

Change-Id: Id8b6352e8dda69782129dcea8f67203fd9c4f572
2015-08-14 10:45:46 -07:00
James Zern
2dec09426a mkvparser: normalize UnserializeInt signature
long size -> long long; fixes a conversion warning under visual studio

Change-Id: I216151236f4ad7e1b8af4d8b7d19e3b36083fd14
2015-08-04 19:01:06 -07:00
Francisco Facioni
b6de61a5c0 Adds support for simple tags
Change-Id: I285e4b73df0a7112bbde7ef13eddf8fdccf59178
2015-07-22 17:07:25 -03:00
Vignesh Venkatasubramanian
7affc5c3f8 clang-format re-run
Re-run clang-format to pick up some missed changes over the past
few CLs. Also update the .clang-format file to break after ternary
operator.

Change-Id: Ia4ba4e58362c2dbe36aeb33894f0411af33ef17d
2015-06-04 16:48:48 -07:00
Frank Galligan
d66ba4470a Merge "Add support to parse DisplayUnit." 2015-06-03 00:25:32 +00:00
Frank Galligan
deb41c2ea1 Add support to parse DisplayUnit.
BUG=https://code.google.com/p/webm/issues/detail?id=1009

Change-Id: I209ee6caf5bc10dfc1761e650821cc2338a4b13c
2015-06-02 16:17:13 -07:00
Leonel Togniolli
42e5660e73 Fix issues on EBML lacing block parsing
Fix EBML lacing block parsing when attempting to parse the last frame
on single-frame videos and assertion when frame_count is lower
than actual data in the file.

Change-Id: I223e30be54970ef75126c6c4ee3401cbeb92e02f
2015-06-02 15:51:48 -07:00
Leonel Togniolli
fe1e9bba6e Fix block parsing to not allow frame_size = 0
Fixed block parsing to account to cases that would
allow frame_size = 0, only to be rejected later on
Block::GetFrame assert(f.len > 0);

Change-Id: Idb93388b37e1963ec6115ac49f15e4951bc2c724
2015-06-02 15:51:48 -07:00
Leonel Togniolli
2cb6a28b09 Change assertions to checks when parsing TrackPositions
Malformed files woudl cause the parser to assert.

Instead now it stops parsing and skips the segment.

Change-Id: I256b3b72e43f969693ae16547ca98da07d665e21
2015-06-02 15:51:40 -07:00
Leonel Togniolli
d04580fda5 Fixes issues on Block Group parsing
Changed assertions to "invalid file format" errors files that
had Block Groups without Block IDs or had invalid sizes or
durations

Change-Id: I1383a63bfb76ee46aaa0aff089780383ce65fc31
2015-06-02 10:39:09 -07:00
Leonel Togniolli
5a3be734f3 Change assertions to checks when load CuePoints
Malformed files would cause the parser to assert.

Instead now it stops parsing and skips the segment.

Change-Id: I07e3baf5c9eb6feb115e155f226d8abc2c37698e
2015-05-25 01:27:38 +01:00
Tom Finegan
d3849c2f7b mkvparser: Dead code removal.
Change-Id: Ic4cf359ecc80641b97f40c20639ce9c32b34077d
2015-04-14 23:36:29 -07:00
Leonel Togniolli
f439e523b8 Change assertions to checks when preloading Cues
If a malformed webm file contains invalid information on the Cues
the segment, the parser would assert.

Instead, now it ignores the Cues and skips the segment.

Change-Id: I9270f6a0935ce9e9a3765a5f324ae542c1ade1c7
2015-04-14 01:25:25 +01:00
Sasi Inguva
e3616a6614 Add support to parse stereo mode, display width and display height in mkvparser
Change-Id: I7ff99275b70e96b84601c32836f1b79f95fcf0d4
2015-03-12 00:25:58 -07:00
Vignesh Venkatasubramanian
a4b68f825e parser: Fix bug in Chapters::Atom::Parse()
Reading the UID is considered to be failed only if status is < 0
and not the value read.

Change-Id: I88fee3aa5b8c323d099930a6823406c012b70f81
2015-03-03 12:08:28 -08:00
Vignesh Venkatasubramanian
b0f8a81df9 parser: Fix memory leak in Chapter parsing
Fix a memory leak in parsing Chapters element.

Change-Id: I95324299014174d3f0926d96022eeb747b07d1a7
2015-02-06 15:17:28 -08:00
Lajos Molnar
27bb7476dd allow subtitle tracks with ContentEncodings
This is allowed by matroska spec

Change-Id: I1842b6e7c6bab4ba0f86938bbe6b110be0c5435f
2015-01-13 12:56:25 -08:00
James Zern
623d182613 DoLoadCluster: tolerate empty clusters
previously only empty clusters of known size were accepted; with
clusters of unknown size the cluster has been successfully parsed and a
working copy of the file position updated, so parsing can continue.
clusters of this type are discarded as clusters of known size currently
are.

Change-Id: I3ef848768519ab7f1887a11629c50af72249cead
2014-10-01 12:53:14 -07:00
James Zern
8f2d1b3cde mkvparser: fix DiscardPadding extraction
the element length was being read twice; the second attempt would
consume a portion of the discard padding field often failing due to
limitations in GetUIntLength.

Change-Id: Ibbe3f082e2d05460734a0e1f7d23f3c665e3f24b
2014-05-30 14:44:28 -07:00
Vignesh Venkatasubramanian
d13c017744 UUIDs can have their high bit set
mkvparser::UnserializeUInt() assumes that unsigned values never have
their high bit set. This is too limiting for UUIDs. In addition, the
Chapters::Atom::Parse() method would truncate a "negative" 64-bit UUID
value to 32 bits and return the truncated value as a status code.
This value then might or might not be treated as an error by the caller
depending on whether the truncated value was itself negative.

Change-Id: I15624ac62d0b02691a1405ee6a5f7eb441b3bc48
2014-05-16 11:25:22 -07:00
Vignesh Venkatasubramanian
7f3cda494a mkvparser: fix a bunch of windows warnings
fix a bunch of windows warnings in parser.

Change-Id: Ia9a03879540595306d8fa2b90ceb9b3b5b0d93a6
2014-05-01 13:50:19 -07:00
Vignesh Venkatasubramanian
4df111e60a clang-format on mkvparser.[ch]pp
Conformance of mkvparser.[ch]pp to Google C++ style guide.

Change-Id: I459adac3da1496b432b71b3580b4dbd63037df2b
2014-04-29 11:30:00 -07:00
Tom Finegan
8ae2137637 mkvparser: Silence MSVC warning that suggests making code non-portable.
Change-Id: Ia8b4cd39711105a5b3462b512160f9250e8a5966
2014-02-25 09:36:32 -08:00
Tom Finegan
d58f55542f mkvparser: Fix unused variable warnings when NDEBUG is defined.
Change-Id: I98b1121768e5650c2184acbf35636a15e9241148
2014-02-05 20:44:29 -08:00