mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-11 18:36:11 +02:00
encrypt return emtpy if exceed max len to avoid another encrypt
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
9cba0a0b89
commit
e1ae3601c4
1 changed files with 6 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue