mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: add length of data for cleanly remove padding
This commit is contained in:
parent
3ef86dedec
commit
65c5f337a9
|
|
@ -248,9 +248,13 @@ print_r($xfss[$this->cipher]);
|
|||
// return false if unable to open file
|
||||
$msg = "encrypt_file: cannot open ".$dst_filename." ";
|
||||
if (!$dest_fp) trigger_error($msg, E_USER_ERROR);
|
||||
|
||||
// adds length of content for cleanly removing the padding
|
||||
$length = strlen($filecontents);
|
||||
$cleanfilecontents = $length.'|'.$filecontents;
|
||||
|
||||
// write encrypted data to file
|
||||
fwrite($dest_fp, $this->encrypt($filecontents));
|
||||
fwrite($dest_fp, $this->encrypt($cleanfilecontents));
|
||||
|
||||
// close encrypted file pointer
|
||||
fclose($dest_fp);
|
||||
|
|
@ -302,6 +306,10 @@ print_r($xfss[$this->cipher]);
|
|||
|
||||
// decrypt file contents
|
||||
$contents = $this->decrypt($contents);
|
||||
|
||||
// remove the padding
|
||||
list($length, $padded_data) = explode('|', $contents, 2);
|
||||
$contents = substr($padded_data, 0, $length);
|
||||
|
||||
// make sure contents where not modified
|
||||
if( $this->efc['crc'] != $this->CRC16HexDigest($contents))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user