Empty legacy packet

This commit is contained in:
QuantumEntangledAndy committed 2023-08-04 19:53:02 +07:00
1 parent 6b60ee6bcc
commit af899d3cfd
4 files changed
+17 -12

No files matched your search

+2
View File
@@ -128,6 +128,8 @@ pub enum LegacyMsg {
/// Password for a legacy login
password: String,
},
/// Sent to upgrade to modern and not exposed the MD5 username/password
LoginUpgrade,
/// Any other type of legacy message will be collected here
UnknownMsg,
}
+4
View File
@@ -130,6 +130,10 @@ fn bc_legacy<W: Write>(legacy: &'_ LegacyMsg) -> impl SerializeFn<W> + '_ {
slice(&[0u8; 1772][..]),
))(out)
}
LoginUpgrade => {
// Write nothing as it is header only
slice(&[])(out)
}
UnknownMsg => {
panic!("Cannot serialize an unknown message!");
}
@@ -282,7 +282,9 @@ impl UdpPayloadSource {
self.send_buffer.push_back(BcUdp::Data(resend.clone()));
}
}
if self.ack_interval.poll_tick(cx).is_ready() && self.packets_want > 0 {
if self.ack_interval.poll_tick(cx).is_ready()
// && self.packets_want > 0
{
let ack = BcUdp::Ack(self.build_send_ack());
self.send_buffer.push_back(ack);
self.state = State::Flushing;
+8 -11
View File
@@ -1,4 +1,4 @@
use super::{md5_string, BcCamera, Error, Result, Truncate, ZeroLast};
use super::{md5_string, BcCamera, Error, Result, Truncate};
use crate::bc::{model::*, xml::*};
use std::sync::atomic::Ordering;
@@ -48,12 +48,12 @@ impl BcCamera {
// Note: I suspect there may be a buffer overflow opportunity in the firmware since in the
// Baichuan library, these strings are capped at 32 bytes with a null terminator. This
// could also be a mistake in the library, the effect being it only compares 31 chars, not 32.
let md5_username = md5_string(&credentials.username, ZeroLast);
let md5_password = credentials
.password
.as_ref()
.map(|p| md5_string(p, ZeroLast))
.unwrap_or_else(|| EMPTY_LEGACY_PASSWORD.to_owned());
// let md5_username = md5_string(&credentials.username, ZeroLast);
// let md5_password = credentials
// .password
// .as_ref()
// .map(|p| md5_string(p, ZeroLast))
// .unwrap_or_else(|| EMPTY_LEGACY_PASSWORD.to_owned());
let enc_byte = match max_encryption {
MaxEncryption::None => 0xdc00,
@@ -69,10 +69,7 @@ impl BcCamera {
response_code: enc_byte,
class: 0x6514,
},
body: BcBody::LegacyMsg(LegacyMsg::LoginMsg {
username: md5_username,
password: md5_password,
}),
body: BcBody::LegacyMsg(LegacyMsg::LoginUpgrade),
};
sub_login.send(legacy_login).await?;