Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eef4ae44 authored by Christopher Tate's avatar Christopher Tate
Browse files

Fix bug where sometimes the full backup pw would not be validated

There was a hole where if no backup pw was supplied and the current
pw authentication field was also left blank, it wound up not verifying
and just proceeding with the backup.

Change-Id: I857d8e83cbb2b3bf6b6b04848c5696ef0cf393a1
parent e83af902
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -2034,6 +2034,15 @@ class BackupManagerService extends IBackupManager.Stub {
                boolean compressing = COMPRESS_FULL_BACKUPS;
                OutputStream finalOutput = ofstream;

                // Verify that the given password matches the currently-active
                // backup password, if any
                if (hasBackupPassword()) {
                    if (!passwordMatchesSaved(mCurrentPassword, PBKDF2_HASH_ROUNDS)) {
                        if (DEBUG) Slog.w(TAG, "Backup password mismatch; aborting");
                        return;
                    }
                }

                // Write the global file header.  All strings are UTF-8 encoded; lines end
                // with a '\n' byte.  Actual backup data begins immediately following the
                // final '\n'.
@@ -2068,15 +2077,6 @@ class BackupManagerService extends IBackupManager.Stub {
                try {
                    // Set up the encryption stage if appropriate, and emit the correct header
                    if (encrypting) {
                        // Verify that the given password matches the currently-active
                        // backup password, if any
                        if (hasBackupPassword()) {
                            if (!passwordMatchesSaved(mCurrentPassword, PBKDF2_HASH_ROUNDS)) {
                                if (DEBUG) Slog.w(TAG, "Backup password mismatch; aborting");
                                return;
                            }
                        }

                        finalOutput = emitAesBackupHeader(headerbuf, finalOutput);
                    } else {
                        headerbuf.append("none\n");