Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: media/formats/webm/webm_parser.cc

Issue 251583003: Ensure DiscardPadding is parsed as a signed integer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove bad rebase. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/formats/webm/webm_cluster_parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/webm/webm_parser.h" 5 #include "media/formats/webm/webm_parser.h"
6 6
7 // This file contains code to parse WebM file elements. It was created 7 // This file contains code to parse WebM file elements. It was created
8 // from information in the Matroska spec. 8 // from information in the Matroska spec.
9 // http://www.matroska.org/technical/specs/index.html 9 // http://www.matroska.org/technical/specs/index.html
10 // This file contains code for encrypted WebM. Current WebM 10 // This file contains code for encrypted WebM. Current WebM
11 // encrypted request for comments specification is here 11 // encrypted request for comments specification is here
12 // http://wiki.webmproject.org/encryption/webm-encryption-rfc 12 // http://wiki.webmproject.org/encryption/webm-encryption-rfc
13 13
14 #include <iomanip> 14 #include <iomanip>
15 15
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/numerics/safe_conversions.h"
17 #include "media/formats/webm/webm_constants.h" 18 #include "media/formats/webm/webm_constants.h"
18 19
19 namespace media { 20 namespace media {
20 21
21 enum ElementType { 22 enum ElementType {
22 UNKNOWN, 23 UNKNOWN,
23 LIST, // Referred to as Master Element in the Matroska spec. 24 LIST, // Referred to as Master Element in the Matroska spec.
24 UINT, 25 UINT,
25 FLOAT, 26 FLOAT,
26 BINARY, 27 BINARY,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 {UINT, kWebMIdSilentTrackNumber}, 112 {UINT, kWebMIdSilentTrackNumber},
112 }; 113 };
113 114
114 static const ElementIdInfo kBlockGroupIds[] = { 115 static const ElementIdInfo kBlockGroupIds[] = {
115 {BINARY, kWebMIdBlock}, 116 {BINARY, kWebMIdBlock},
116 {LIST, kWebMIdBlockAdditions}, 117 {LIST, kWebMIdBlockAdditions},
117 {UINT, kWebMIdBlockDuration}, 118 {UINT, kWebMIdBlockDuration},
118 {UINT, kWebMIdReferencePriority}, 119 {UINT, kWebMIdReferencePriority},
119 {BINARY, kWebMIdReferenceBlock}, 120 {BINARY, kWebMIdReferenceBlock},
120 {BINARY, kWebMIdCodecState}, 121 {BINARY, kWebMIdCodecState},
121 {UINT, kWebMIdDiscardPadding}, 122 {BINARY, kWebMIdDiscardPadding},
122 {LIST, kWebMIdSlices}, 123 {LIST, kWebMIdSlices},
123 }; 124 };
124 125
125 static const ElementIdInfo kBlockAdditionsIds[] = { 126 static const ElementIdInfo kBlockAdditionsIds[] = {
126 {LIST, kWebMIdBlockMore}, 127 {LIST, kWebMIdBlockMore},
127 }; 128 };
128 129
129 static const ElementIdInfo kBlockMoreIds[] = { 130 static const ElementIdInfo kBlockMoreIds[] = {
130 {UINT, kWebMIdBlockAddID}, 131 {UINT, kWebMIdBlockAddID},
131 {BINARY, kWebMIdBlockAdditional}, 132 {BINARY, kWebMIdBlockAdditional},
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 542
542 return -1; 543 return -1;
543 } 544 }
544 545
545 static int ParseUInt(const uint8* buf, int size, int id, 546 static int ParseUInt(const uint8* buf, int size, int id,
546 WebMParserClient* client) { 547 WebMParserClient* client) {
547 if ((size <= 0) || (size > 8)) 548 if ((size <= 0) || (size > 8))
548 return -1; 549 return -1;
549 550
550 // Read in the big-endian integer. 551 // Read in the big-endian integer.
551 int64 value = 0; 552 uint64 value = 0;
552 for (int i = 0; i < size; ++i) 553 for (int i = 0; i < size; ++i)
553 value = (value << 8) | buf[i]; 554 value = (value << 8) | buf[i];
554 555
556 // We use int64 in place of uint64 everywhere for convenience. See this bug
557 // for more details: http://crbug.com/366750#c3
558 if (!base::IsValueInRangeForNumericType<int64>(value))
559 return -1;
560
555 if (!client->OnUInt(id, value)) 561 if (!client->OnUInt(id, value))
556 return -1; 562 return -1;
557 563
558 return size; 564 return size;
559 } 565 }
560 566
561 static int ParseFloat(const uint8* buf, int size, int id, 567 static int ParseFloat(const uint8* buf, int size, int id,
562 WebMParserClient* client) { 568 WebMParserClient* client) {
563 569
564 if ((size != 4) && (size != 8)) 570 if ((size != 4) && (size != 8))
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 if (kSegmentIds[i].id_ == id_b) 944 if (kSegmentIds[i].id_ == id_b)
939 return true; 945 return true;
940 } 946 }
941 } 947 }
942 948
943 // kWebMIdSegment siblings. 949 // kWebMIdSegment siblings.
944 return ((id_b == kWebMIdSegment) || (id_b == kWebMIdEBMLHeader)); 950 return ((id_b == kWebMIdSegment) || (id_b == kWebMIdEBMLHeader));
945 } 951 }
946 952
947 } // namespace media 953 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/webm/webm_cluster_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698