fix typo in RTCP padding parsing
This was accidentally looking at the bottom bit of the V=2 field, so it effectively never subtracted padding from the payload. This bug didn't have any effect...yet. We currently only support parsing the sender report. RFC 3550 says that SRs are sent in "compound packets" that start with the SR and have at least one other entry (a CNAME). Only the last packet within the compound packet can have padding, so it's never come up in SR parsing. Fix this bug now before we start parsing more things and run into trouble.
This commit is contained in:
parent
375754a88f
commit
9bc2c8eca5
11
src/rtcp.rs
11
src/rtcp.rs
@ -138,7 +138,7 @@ impl<'a> GenericPacket<'a> {
|
||||
));
|
||||
}
|
||||
let (this, rest) = buf.split_at(len);
|
||||
let padding_bit = this[0] & 0b00100_0000;
|
||||
let padding_bit = this[0] & 0b0010_0000;
|
||||
if padding_bit != 0 {
|
||||
if raw_len == 0 {
|
||||
return Err("RTCP packet has invalid combination of padding and len=0".to_owned());
|
||||
@ -209,4 +209,13 @@ mod tests {
|
||||
}
|
||||
assert_eq!(buf.len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn padding() {
|
||||
let buf = b"\xa7\x00\x00\x02asdf\x00\x00\x00\x04rest";
|
||||
let (pkt, rest) = GenericPacket::parse(buf).unwrap();
|
||||
assert_eq!(pkt.count(), 7);
|
||||
assert_eq!(&pkt.buf[4..pkt.payload_end], b"asdf");
|
||||
assert_eq!(b"rest", rest);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user