Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 3b55a14

Browse files
msfjarvisSkrilltrax
andcommitted
Disallow overwriting passwords when editing (#1286)
Co-authored-by: Aditya Wasan <[email protected]> (cherry picked from commit 1f8db46)
1 parent 66e17fd commit 3b55a14

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Fixed
8+
9+
- Editing a password allowed accidentally overwriting an existing one
10+
11+
712
## [1.13.2] - 2020-12-20
813

914
### Added

app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
397397
runCatching {
398398
val file = File(path)
399399
// If we're not editing, this file should not already exist!
400-
if (!editing && file.exists()) {
400+
// Additionally, if we were editing and the incoming and outgoing
401+
// filenames differ, it means we renamed. Ensure that the target
402+
// doesn't already exist to prevent an accidental overwrite.
403+
if ((!editing || (editing && suggestedName != file.nameWithoutExtension)) && file.exists()) {
401404
snackbar(message = getString(R.string.password_creation_duplicate_error))
402405
return@executeApiAsync
403406
}

0 commit comments

Comments
 (0)