Bug 1313527: exit red parser loop if stroul failed. r=mjf
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Thu, 27 Oct 2016 16:48:10 -0700
changeset 319928 aeb0df69182a4c13eb06f9a7f18bd66c437ce245
parent 319927 5e28fc45d1364e909cbefbf078ba2ea3b26eeb53
child 319929 9c50b4bafe2ebb801bb5168b8ca5db2b02596e77
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjf
bugs1313527
milestone52.0a1
Bug 1313527: exit red parser loop if stroul failed. r=mjf MozReview-Commit-ID: JaRO7F7tz0j
media/webrtc/signaling/src/sdp/sipcc/sdp_attr.c
media/webrtc/signaling/test/sdp_unittests.cpp
--- a/media/webrtc/signaling/src/sdp/sipcc/sdp_attr.c
+++ b/media/webrtc/signaling/src/sdp/sipcc/sdp_attr.c
@@ -1323,18 +1323,19 @@ sdp_result_e sdp_parse_attr_fmtp (sdp_t 
             temp=PL_strtok_r(tmp, "/", &strtok_state);
             if (temp) {
                 iter = 0;
                 while (temp != NULL) {
                     errno = 0;
                     strtoul_result = strtoul(temp, &strtoul_end, 10);
 
                     if (errno ||
-                        temp == strtoul_end || strtoul_result > USHRT_MAX) {
-                        continue;
+                       temp == strtoul_end || strtoul_result > USHRT_MAX) {
+                      temp = NULL;
+                      continue;
                     }
                     fmtp_p->redundant_encodings[iter++] =
                         (uint8_t)strtoul_result;
                     temp=PL_strtok_r(NULL, "/", &strtok_state);
                 }
             } /* if (temp) */
         } else if (SDP_SUCCESS == sdp_verify_attr_fmtp_telephone_event(tmp)) {
           // XXX Note that DTMF fmtp will fall into here:
--- a/media/webrtc/signaling/test/sdp_unittests.cpp
+++ b/media/webrtc/signaling/test/sdp_unittests.cpp
@@ -436,16 +436,30 @@ TEST_F(SdpTest, parseRtcpFbFoo) {
 TEST_F(SdpTest, parseRtcpFbFooBar) {
   ParseSdp(kVideoSdp + "a=rtcp-fb:120 foo bar\r\n");
 }
 
 TEST_F(SdpTest, parseRtcpFbFooBarBaz) {
   ParseSdp(kVideoSdp + "a=rtcp-fb:120 foo bar baz\r\n");
 }
 
+static const std::string kVideoSdpWithUnknonwBrokenFtmp =
+  "v=0\r\n"
+  "o=- 4294967296 2 IN IP4 127.0.0.1\r\n"
+  "s=SIP Call\r\n"
+  "c=IN IP4 198.51.100.7\r\n"
+  "t=0 0\r\n"
+  "m=video 56436 RTP/SAVPF 120\r\n"
+  "a=rtpmap:120 VP8/90000\r\n"
+  "a=fmtp:122 unknown=10\n"
+  "a=rtpmap:122 red/90000\r\n";
+
+TEST_F(SdpTest, parseUnknownBrokenFtmp) {
+  ParseSdp(kVideoSdpWithUnknonwBrokenFtmp);
+}
 
 TEST_F(SdpTest, parseRtcpFbKitchenSink) {
   ParseSdp(kVideoSdp +
     "a=rtcp-fb:120 ack rpsi\r\n"
     "a=rtcp-fb:120 ack app\r\n"
     "a=rtcp-fb:120 ack app foo\r\n"
     "a=rtcp-fb:120 ack foo bar\r\n"
     "a=rtcp-fb:120 ack foo bar baz\r\n"