diff --git a/src/Rtsp/RtpReceiver.cpp b/src/Rtsp/RtpReceiver.cpp index 80cb170f..fad2a5d5 100644 --- a/src/Rtsp/RtpReceiver.cpp +++ b/src/Rtsp/RtpReceiver.cpp @@ -98,7 +98,14 @@ bool RtpReceiver::handleOneRtp(int iTrackidx,SdpTrack::Ptr &track, unsigned char ext = (AV_RB16(pucData + rtppt.offset - 2) + 1) << 2; rtppt.offset += ext; } + if(rtppt.length - rtppt.offset <= 0){ + WarnL << "无有效负载的rtp包:" << rtppt.length << "<=" << (int)rtppt.offset; + return false; + } + + if(uiLen > sizeof(rtppt.payload) - 4){ + WarnL << "超长的rtp包:" << uiLen << ">" << sizeof(rtppt.payload) - 4; return false; } memcpy(rtppt.payload + 4, pucData, uiLen); diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 183bc8eb..9d8897f8 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -447,6 +447,7 @@ void RtspPlayer::onWholeRtspPacket(Parser &parser) { void RtspPlayer::onRtpPacket(const char *data, uint64_t len) { if(len > 1600){ //没有大于MTU的包 + WarnL << "大于MTU的RTP包:" << len << ",来自:" << get_peer_ip(); return; } int trackIdx = -1; diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 2fe7fa0c..493a0767 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -1,4 +1,4 @@ -/* +/* * MIT License * * Copyright (c) 2016 xiongziliang <771730766@qq.com> @@ -188,6 +188,7 @@ void RtspSession::onRtpPacket(const char *data, uint64_t len) { } if(len > 1600){ //没有大于MTU的包 + WarnL << "大于MTU的RTP包:" << len << ",来自:" << get_peer_ip(); return; } int trackIdx = -1; diff --git a/src/RtspMuxer/RtpCodec.h b/src/RtspMuxer/RtpCodec.h index 5324ba84..409ac398 100644 --- a/src/RtspMuxer/RtpCodec.h +++ b/src/RtspMuxer/RtpCodec.h @@ -46,7 +46,7 @@ public: uint32_t timeStamp; uint16_t sequence; uint32_t ssrc; - uint8_t payload[1560]; + uint8_t payload[1600]; uint8_t offset; TrackType type; };