Merge pull request #5444 from 21pages/fix

encrypt return emtpy if exceed max len to avoid another encrypt
This commit is contained in:
RustDesk 2023-08-19 22:00:32 +08:00 committed by GitHub
commit 7c9068cf17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();