From 6bdd74584ef3f261a090ec81622bbc1aee55356f Mon Sep 17 00:00:00 2001 From: Kenneth Endfinger Date: Mon, 23 Jul 2018 17:40:41 -0500 Subject: [PATCH] Fix file encoding migration Summary: See [[ https://discourse.phabricator-community.org/t/file-encryption-corruption-when-trying-to-encode-existing-files/1605 | Discourse ]] When migrating to aes-256-cbc, integrity hashes were not updated, so data was not properly Test Plan: I ran [[ https://gist.github.com/kaendfinger/3e0d78350af0ebe4e74b2c8a79707bae | this test script ]] to ensure it worked. I created some files with lipsum, ensured that after encoding them with aes-256-cbc, they were not able to be cat'd. After applying this patch and rerunning the script, it worked successfully. Reviewers: epriestley, amckinley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Tags: #files, #storage Differential Revision: https://secure.phabricator.com/D19533 --- src/applications/files/storage/PhabricatorFile.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php index b795678cd2..1517b4435b 100644 --- a/src/applications/files/storage/PhabricatorFile.php +++ b/src/applications/files/storage/PhabricatorFile.php @@ -492,12 +492,13 @@ final class PhabricatorFile extends PhabricatorFileDAO $this->setStorageFormat($format->getStorageFormatKey()); $this->setStorageProperties($properties); - list($identifier, $new_handle) = $this->writeToEngine( + list($identifier, $new_handle, $integrity_hash) = $this->writeToEngine( $engine, $data, $params); $this->setStorageHandle($new_handle); + $this->setIntegrityHash($integrity_hash); $this->save(); $this->deleteFileDataIfUnused(