Bug 1306714: Use RFC 7983 detection for DTLS packets. r=mt
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Fri, 30 Sep 2016 00:00:54 -0700
changeset 362374 ef16dca832723f5023ee5af5ddcf87a02d1e9188
parent 362373 aa146c955d97342917b8af5adbb36da09648aeae
child 362375 a151abb7d9f8f6ebd044e2b3e02e89b0bf20ebe5
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt
bugs1306714
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1306714: Use RFC 7983 detection for DTLS packets. r=mt MozReview-Commit-ID: L1BYAFmJOug
media/mtransport/transportlayerdtls.cpp
--- a/media/mtransport/transportlayerdtls.cpp
+++ b/media/mtransport/transportlayerdtls.cpp
@@ -978,28 +978,32 @@ void TransportLayerDtls::PacketReceived(
   MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")");
 
   if (state_ != TS_CONNECTING && state_ != TS_OPEN) {
     MOZ_MTLOG(ML_DEBUG,
               LAYER_INFO << "Discarding packet in inappropriate state");
     return;
   }
 
+  // not DTLS per RFC 7983
+  if (data[0] < 20 || data[0] > 63) {
+    return;
+  }
+
   nspr_io_adapter_->PacketReceived(data, len);
 
   // If we're still connecting, try to handshake
   if (state_ == TS_CONNECTING) {
     Handshake();
   }
 
   // Now try a recv if we're open, since there might be data left
   if (state_ == TS_OPEN) {
     // nICEr uses a 9216 bytes buffer to allow support for jumbo frames
     unsigned char buf[9216];
-
     int32_t rv;
     // One packet might contain several DTLS packets
     do {
       rv = PR_Recv(ssl_fd_, buf, sizeof(buf), 0, PR_INTERVAL_NO_WAIT);
       if (rv > 0) {
         // We have data
         MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Read " << rv << " bytes from NSS");
         SignalPacketReceived(this, buf, rv);