Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

encrypt return emtpy if exceed max len to avoid another encrypt

21pagese1ae3601c422
diff --git a/libs/hbb_common/src/password_security.rs b/libs/hbb_common/src/password_security.rs
index 28b32e68e..64dce1fdc 100644
--- a/libs/hbb_common/src/password_security.rs
+++ b/libs/hbb_common/src/password_security.rs
@@ -89,6 +89,9 @@ pub fn encrypt_str_or_original(s: &str, version: &str, max_len: usize) -> String
log::error!("Duplicate encryption!");
return s.to_owned();
}
+ if s.bytes().len() > max_len {
+ return String::default();
+ }
if version == "00" {
if let Ok(s) = encrypt(s.as_bytes(), max_len) {
return version.to_owned() + &s;
@@ -122,6 +125,9 @@ pub fn encrypt_vec_or_original(v: &[u8], version: &str, max_len: usize) -> Vec<u
log::error!("Duplicate encryption!");
return v.to_owned();
}
+ if v.len() > max_len {
+ return vec![];
+ }
if version == "00" {
if let Ok(s) = encrypt(v, max_len) {
let mut version = version.to_owned().into_bytes();