diff --git a/CHANGELOG.md b/CHANGELOG.md index 82cf20f..beed890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ -## unreleased +## `v0.4.5` (2023-02-02) * minimum Rust version is now 1.64. +* upgrade to `rtsp-types` 0.0.5, which ignores trailing whitespace in RTSP + headers. This fixes errors when communicating with some Longse cameras + ([#77](https://github.com/scottlamb/retina/pull/77)). * remove obsolete workaround for GW security GW security GW4089IP's bad out-of-band parameters. Instead, we treat them as unparseable and ignore them as described in the `v0.4.2` notes below. diff --git a/Cargo.lock b/Cargo.lock index 88422ed..e397479 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1869,7 +1869,7 @@ checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "retina" -version = "0.4.4" +version = "0.4.5" dependencies = [ "base64", "bitstream-io", @@ -1958,9 +1958,9 @@ dependencies = [ [[package]] name = "rtsp-types" -version = "0.0.3" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b668122d4d00c479c08fb2a0a253669832606ccca80832a6b99bb5288ab4f75" +checksum = "2a1aec90dc5d8dec85c14032885770801439acb1651b2f166745ce482a2ddeaf" dependencies = [ "cookie-factory", "nom 7.1.1", diff --git a/Cargo.toml b/Cargo.toml index 7c48482..51d2dc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["."] [package] name = "retina" -version = "0.4.4" +version = "0.4.5" authors = ["Scott Lamb "] license = "MIT/Apache-2.0" edition = "2021" @@ -28,7 +28,7 @@ once_cell = "1.7.2" pin-project = "1.0.7" pretty-hex = "0.3.0" rand = "0.8.3" -rtsp-types = "0.0.3" +rtsp-types = "0.0.5" sdp-types = "0.1.4" smallvec = { version = "1.6.1", features = ["union"] } thiserror = "1.0.25" diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index a68b070..e89711c 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -515,7 +515,7 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "retina" -version = "0.4.4" +version = "0.4.5" dependencies = [ "base64", "bitstream-io", @@ -561,9 +561,9 @@ dependencies = [ [[package]] name = "rtsp-types" -version = "0.0.3" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b668122d4d00c479c08fb2a0a253669832606ccca80832a6b99bb5288ab4f75" +checksum = "2a1aec90dc5d8dec85c14032885770801439acb1651b2f166745ce482a2ddeaf" dependencies = [ "cookie-factory", "nom", diff --git a/src/client/parse.rs b/src/client/parse.rs index bd5fb47..eb8ab14 100644 --- a/src/client/parse.rs +++ b/src/client/parse.rs @@ -742,6 +742,26 @@ mod tests { }) } + /// Longse cameras, for whatever reason, have trailing whitespace in their `CSeq` header lines. + /// + /// This test ensures this is correctly stripped. RTSP follows HTTP's lead for request/response + /// parsing (see [RFC 2326 section + /// 4.1](https://www.rfc-editor.org/rfc/rfc2326.html#page-19)), and HTTP [RFC + /// 9110 section 5.5](https://www.rfc-editor.org/rfc/rfc9110#name-field-values) says the following: + /// + /// > A field value does not include leading or trailing whitespace. When a + /// > specific version of HTTP allows such whitespace to appear in a message, + /// > a field parsing implementation MUST exclude such whitespace prior to + /// > evaluating the field value. + /// + /// Currently we rely on `rtsp-types` doing the stripping. + #[test] + fn longse_cseq() { + init_logging(); + let response = response(include_bytes!("testdata/longse_unauthorized.txt")); + assert_eq!(super::get_cseq(&response), Some(1)); + } + #[test] fn anvpiz_sdp() { init_logging(); diff --git a/src/client/testdata/longse_unauthorized.txt b/src/client/testdata/longse_unauthorized.txt new file mode 100644 index 0000000..85bc7e2 --- /dev/null +++ b/src/client/testdata/longse_unauthorized.txt @@ -0,0 +1,5 @@ +RTSP/1.0 401 Unauthorized +CSeq: 1 +Server: Rtsp Server 1920*1080*20*2048 +WWW-Authenticate: Digest realm="Surveillance Server", nonce="98481030" +