Skip to content

Commit 4ae548e

Browse files
committed
Bail out early if ptp header version is not 2
v1 is not supported, so let's not show v1 packets at all.
1 parent 9675a1e commit 4ae548e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/types.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,10 @@ impl TryFrom<&[u8]> for PtpMessage {
11101110
fn try_from(data: &[u8]) -> Result<Self, Self::Error> {
11111111
let header = PtpHeader::try_from(&data[..34])?;
11121112

1113+
if header.version != PtpVersion::V2 {
1114+
return Err(anyhow::anyhow!("Unsupported PTP version"));
1115+
}
1116+
11131117
match header.message_type {
11141118
PtpMessageType::Announce => Ok(PtpMessage::Announce(AnnounceMessage::try_from(data)?)),
11151119
PtpMessageType::DelayReq => Ok(PtpMessage::DelayReq(DelayReqMessage::try_from(data)?)),

0 commit comments

Comments
 (0)