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

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

Issue 2498903003: Fix parsing padding byte in rtp header extension (Closed)
Patch Set: double check packet set correctly Created 4 years 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
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // +-+-+-+-+-+-+-+-+ 311 // +-+-+-+-+-+-+-+-+
312 // | ID | len | 312 // | ID | len |
313 // +-+-+-+-+-+-+-+-+ 313 // +-+-+-+-+-+-+-+-+
314 314
315 // Note that 'len' is the header extension element length, which is the 315 // Note that 'len' is the header extension element length, which is the
316 // number of bytes - 1. 316 // number of bytes - 1.
317 const int id = (*ptr & 0xf0) >> 4; 317 const int id = (*ptr & 0xf0) >> 4;
318 const int len = (*ptr & 0x0f); 318 const int len = (*ptr & 0x0f);
319 ptr++; 319 ptr++;
320 320
321 if (id == 0) {
322 // Padding byte, skip ignoring len.
323 continue;
324 }
325
321 if (id == 15) { 326 if (id == 15) {
322 LOG(LS_WARNING) 327 LOG(LS_VERBOSE)
323 << "RTP extension header 15 encountered. Terminate parsing."; 328 << "RTP extension header 15 encountered. Terminate parsing.";
324 return; 329 return;
325 } 330 }
326 331
327 if (ptrRTPDataExtensionEnd - ptr < (len + 1)) { 332 if (ptrRTPDataExtensionEnd - ptr < (len + 1)) {
328 LOG(LS_WARNING) << "Incorrect one-byte extension len: " << (len + 1) 333 LOG(LS_WARNING) << "Incorrect one-byte extension len: " << (len + 1)
329 << ", bytes left in buffer: " 334 << ", bytes left in buffer: "
330 << (ptrRTPDataExtensionEnd - ptr); 335 << (ptrRTPDataExtensionEnd - ptr);
331 return; 336 return;
332 } 337 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 max_playout_delay * kPlayoutDelayGranularityMs; 444 max_playout_delay * kPlayoutDelayGranularityMs;
440 break; 445 break;
441 } 446 }
442 default: { 447 default: {
443 LOG(LS_WARNING) << "Extension type not implemented: " << type; 448 LOG(LS_WARNING) << "Extension type not implemented: " << type;
444 return; 449 return;
445 } 450 }
446 } 451 }
447 } 452 }
448 ptr += (len + 1); 453 ptr += (len + 1);
449 uint8_t num_bytes = ParsePaddingBytes(ptrRTPDataExtensionEnd, ptr);
450 ptr += num_bytes;
451 } 454 }
452 } 455 }
453 456
454 uint8_t RtpHeaderParser::ParsePaddingBytes(
455 const uint8_t* ptrRTPDataExtensionEnd,
456 const uint8_t* ptr) const {
457 uint8_t num_zero_bytes = 0;
458 while (ptrRTPDataExtensionEnd - ptr > 0) {
459 if (*ptr != 0) {
460 return num_zero_bytes;
461 }
462 ptr++;
463 num_zero_bytes++;
464 }
465 return num_zero_bytes;
466 }
467 } // namespace RtpUtility 457 } // namespace RtpUtility
468 } // namespace webrtc 458 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_utility.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_utility_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698