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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_utility.cc

Issue 1870573004: Fixed rtcp rpsi parsing of invalid packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_utility.h ('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 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 break; 123 break;
124 case ParseState::State_RTPFB_TMMBRItem: 124 case ParseState::State_RTPFB_TMMBRItem:
125 IterateTMMBRItem(); 125 IterateTMMBRItem();
126 break; 126 break;
127 case ParseState::State_RTPFB_TMMBNItem: 127 case ParseState::State_RTPFB_TMMBNItem:
128 IterateTMMBNItem(); 128 IterateTMMBNItem();
129 break; 129 break;
130 case ParseState::State_PSFB_SLIItem: 130 case ParseState::State_PSFB_SLIItem:
131 IterateSLIItem(); 131 IterateSLIItem();
132 break; 132 break;
133 case ParseState::State_PSFB_RPSIItem:
134 IterateRPSIItem();
135 break;
136 case ParseState::State_PSFB_FIRItem: 133 case ParseState::State_PSFB_FIRItem:
137 IterateFIRItem(); 134 IterateFIRItem();
138 break; 135 break;
139 case ParseState::State_PSFB_AppItem: 136 case ParseState::State_PSFB_AppItem:
140 IteratePsfbAppItem(); 137 IteratePsfbAppItem();
141 break; 138 break;
142 case ParseState::State_PSFB_REMBItem: 139 case ParseState::State_PSFB_REMBItem:
143 IteratePsfbREMBItem(); 140 IteratePsfbREMBItem();
144 break; 141 break;
145 case ParseState::State_XRItem: 142 case ParseState::State_XRItem:
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 RTCPUtility::RTCPParserV2::IterateSLIItem() 355 RTCPUtility::RTCPParserV2::IterateSLIItem()
359 { 356 {
360 const bool success = ParseSLIItem(); 357 const bool success = ParseSLIItem();
361 if (!success) 358 if (!success)
362 { 359 {
363 Iterate(); 360 Iterate();
364 } 361 }
365 } 362 }
366 363
367 void 364 void
368 RTCPUtility::RTCPParserV2::IterateRPSIItem()
369 {
370 const bool success = ParseRPSIItem();
371 if (!success)
372 {
373 Iterate();
374 }
375 }
376
377 void
378 RTCPUtility::RTCPParserV2::IterateFIRItem() 365 RTCPUtility::RTCPParserV2::IterateFIRItem()
379 { 366 {
380 const bool success = ParseFIRItem(); 367 const bool success = ParseFIRItem();
381 if (!success) 368 if (!success)
382 { 369 {
383 Iterate(); 370 Iterate();
384 } 371 }
385 } 372 }
386 373
387 void 374 void
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 case 2: 1253 case 2:
1267 // SLI 1254 // SLI
1268 _packetType = RTCPPacketTypes::kPsfbSli; 1255 _packetType = RTCPPacketTypes::kPsfbSli;
1269 _packet.SLI.SenderSSRC = senderSSRC; 1256 _packet.SLI.SenderSSRC = senderSSRC;
1270 _packet.SLI.MediaSSRC = mediaSSRC; 1257 _packet.SLI.MediaSSRC = mediaSSRC;
1271 1258
1272 _state = ParseState::State_PSFB_SLIItem; 1259 _state = ParseState::State_PSFB_SLIItem;
1273 1260
1274 return true; 1261 return true;
1275 case 3: 1262 case 3:
1276 _packetType = RTCPPacketTypes::kPsfbRpsi;
1277 _packet.RPSI.SenderSSRC = senderSSRC; 1263 _packet.RPSI.SenderSSRC = senderSSRC;
1278 _packet.RPSI.MediaSSRC = mediaSSRC; 1264 _packet.RPSI.MediaSSRC = mediaSSRC;
1279 1265 if (!ParseRPSI()) {
1280 _state = ParseState::State_PSFB_RPSIItem; 1266 _packetType = RTCPPacketTypes::kInvalid;
1267 return false;
1268 }
1281 return true; 1269 return true;
1282 case 4: 1270 case 4:
1283 // FIR 1271 // FIR
1284 _packetType = RTCPPacketTypes::kPsfbFir; 1272 _packetType = RTCPPacketTypes::kPsfbFir;
1285 _packet.FIR.SenderSSRC = senderSSRC; 1273 _packet.FIR.SenderSSRC = senderSSRC;
1286 _packet.FIR.MediaSSRC = mediaSSRC; 1274 _packet.FIR.MediaSSRC = mediaSSRC;
1287 1275
1288 _state = ParseState::State_PSFB_FIRItem; 1276 _state = ParseState::State_PSFB_FIRItem;
1289 return true; 1277 return true;
1290 case 15: 1278 case 15:
1291 _packetType = RTCPPacketTypes::kPsfbApp; 1279 _packetType = RTCPPacketTypes::kPsfbApp;
1292 _packet.PSFBAPP.SenderSSRC = senderSSRC; 1280 _packet.PSFBAPP.SenderSSRC = senderSSRC;
1293 _packet.PSFBAPP.MediaSSRC = mediaSSRC; 1281 _packet.PSFBAPP.MediaSSRC = mediaSSRC;
1294 1282
1295 _state = ParseState::State_PSFB_AppItem; 1283 _state = ParseState::State_PSFB_AppItem;
1296 return true; 1284 return true;
1297 default: 1285 default:
1298 break; 1286 break;
1299 } 1287 }
1300 1288
1301 return false; 1289 return false;
1302 } 1290 }
1303 else 1291 else
1304 { 1292 {
1305 RTC_NOTREACHED(); 1293 RTC_NOTREACHED();
1306 return false; 1294 return false;
1307 } 1295 }
1308 } 1296 }
1309 1297
1310 bool RTCPUtility::RTCPParserV2::ParseRPSIItem() { 1298 bool RTCPUtility::RTCPParserV2::ParseRPSI() {
1311 1299
1312 // RFC 4585 6.3.3. Reference Picture Selection Indication (RPSI). 1300 // RFC 4585 6.3.3. Reference Picture Selection Indication (RPSI).
1313 // 1301 //
1314 // 0 1 2 3 1302 // 0 1 2 3
1315 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1303 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1316 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1304 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1317 // | PB |0| Payload Type| Native RPSI bit string | 1305 // | PB |0| Payload Type| Native RPSI bit string |
1318 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1306 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1319 // | defined per codec ... | Padding (0) | 1307 // | defined per codec ... | Padding (0) |
1320 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1308 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1321 1309
1322 const ptrdiff_t length = _ptrRTCPBlockEnd - _ptrRTCPData; 1310 const ptrdiff_t length = _ptrRTCPBlockEnd - _ptrRTCPData;
1323 1311
1324 if (length < 4) { 1312 if (length < 4) {
1325 _state = ParseState::State_TopLevel;
1326
1327 EndCurrentBlock(); 1313 EndCurrentBlock();
1328 return false; 1314 return false;
1329 } 1315 }
1330 if (length > 2 + RTCP_RPSI_DATA_SIZE) { 1316 if (length > 2 + RTCP_RPSI_DATA_SIZE) {
1331 _state = ParseState::State_TopLevel;
1332
1333 EndCurrentBlock(); 1317 EndCurrentBlock();
1334 return false; 1318 return false;
1335 } 1319 }
1336 1320
1337 _packetType = RTCPPacketTypes::kPsfbRpsi;
1338
1339 uint8_t padding_bits = *_ptrRTCPData++; 1321 uint8_t padding_bits = *_ptrRTCPData++;
1340 _packet.RPSI.PayloadType = *_ptrRTCPData++; 1322 _packet.RPSI.PayloadType = *_ptrRTCPData++;
1341 1323
1342 memcpy(_packet.RPSI.NativeBitString, _ptrRTCPData, length - 2); 1324 memcpy(_packet.RPSI.NativeBitString, _ptrRTCPData, length - 2);
1343 _ptrRTCPData += length - 2; 1325 _ptrRTCPData += length - 2;
1344 1326
1327 if (padding_bits > (length - 2) * 8) {
1328 EndCurrentBlock();
1329 return false;
1330 }
1345 _packet.RPSI.NumberOfValidBits = 1331 _packet.RPSI.NumberOfValidBits =
1346 static_cast<uint16_t>(length - 2) * 8 - padding_bits; 1332 static_cast<uint16_t>(length - 2) * 8 - padding_bits;
1333 _packetType = RTCPPacketTypes::kPsfbRpsi;
1347 return true; 1334 return true;
1348 } 1335 }
1349 1336
1350 bool 1337 bool
1351 RTCPUtility::RTCPParserV2::ParseNACKItem() 1338 RTCPUtility::RTCPParserV2::ParseNACKItem()
1352 { 1339 {
1353 // RFC 4585 6.2.1. Generic NACK 1340 // RFC 4585 6.2.1. Generic NACK
1354 1341
1355 const ptrdiff_t length = _ptrRTCPBlockEnd - _ptrRTCPData; 1342 const ptrdiff_t length = _ptrRTCPBlockEnd - _ptrRTCPData;
1356 1343
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 const RTCPUtility::RtcpCommonHeader* 1690 const RTCPUtility::RtcpCommonHeader*
1704 RTCPUtility::RTCPPacketIterator::Current() { 1691 RTCPUtility::RTCPPacketIterator::Current() {
1705 if (!_ptrBlock) 1692 if (!_ptrBlock)
1706 { 1693 {
1707 return NULL; 1694 return NULL;
1708 } 1695 }
1709 1696
1710 return &_header; 1697 return &_header;
1711 } 1698 }
1712 } // namespace webrtc 1699 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_utility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698