From 4c31ce9c6a309cc4361f70581acc44d2ab2477ac Mon Sep 17 00:00:00 2001 From: Brian Pellin Date: Wed, 26 Aug 2020 21:57:37 -0500 Subject: [PATCH] Prevent database corruption when shrinking database size --- CHANGELOG | 2 ++ app/src/main/java/com/keepassdroid/Database.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 91443a1a..f461dac2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ + * Ensure output files are truncated + KeePassDroid (2.5.12) * Fix storing password with biometrics diff --git a/app/src/main/java/com/keepassdroid/Database.java b/app/src/main/java/com/keepassdroid/Database.java index 36b1b9be..76791953 100644 --- a/app/src/main/java/com/keepassdroid/Database.java +++ b/app/src/main/java/com/keepassdroid/Database.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2017 Brian Pellin. + * Copyright 2009-2020 Brian Pellin. * * This file is part of KeePassDroid. * @@ -214,7 +214,7 @@ public void SaveData(Context ctx, Uri uri) throws IOException, PwDbOutputExcepti else { OutputStream os; try { - os = ctx.getContentResolver().openOutputStream(uri); + os = ctx.getContentResolver().openOutputStream(uri, "wt"); } catch (Exception e) { throw new IOException("Failed to store database."); }