From 238df77a1e4c7675857f5916e9c74f51bd50c541 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 25 Jul 2019 17:01:43 +0200 Subject: [PATCH] catch IllegalArgumentException when reading backup file --- .../eu/siacs/conversations/services/ImportBackupService.java | 2 +- .../java/eu/siacs/conversations/ui/ImportBackupActivity.java | 2 +- .../java/eu/siacs/conversations/utils/BackupFileHeader.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java b/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java index d8246a6af..66ebd7c3a 100644 --- a/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java +++ b/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java @@ -137,7 +137,7 @@ public class ImportBackupService extends Service { } else { backupFiles.add(backupFile); } - } catch (IOException e) { + } catch (IOException | IllegalArgumentException e) { Log.d(Config.LOGTAG, "unable to read backup file ", e); } } diff --git a/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java index d6dbfd222..da4512465 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java @@ -124,7 +124,7 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo try { final ImportBackupService.BackupFile backupFile = ImportBackupService.BackupFile.read(this, uri); showEnterPasswordDialog(backupFile, finishOnCancel); - } catch (IOException e) { + } catch (IOException | IllegalArgumentException e) { Snackbar.make(binding.coordinator, R.string.not_a_backup_file, Snackbar.LENGTH_LONG).show(); } } diff --git a/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java b/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java index bc86a5d24..5e8b80f81 100644 --- a/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java +++ b/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java @@ -49,7 +49,7 @@ public class BackupFileHeader { public static BackupFileHeader read(DataInputStream inputStream) throws IOException { final int version = inputStream.readInt(); if (version > VERSION) { - throw new IllegalArgumentException("Backup File version was "+version+" but app only supports up to version "+VERSION); + throw new IllegalArgumentException("Backup File version was " + version + " but app only supports up to version " + VERSION); } String app = inputStream.readUTF(); String jid = inputStream.readUTF(); @@ -59,7 +59,7 @@ public class BackupFileHeader { byte[] salt = new byte[16]; inputStream.readFully(salt); - return new BackupFileHeader(app,Jid.of(jid),timestamp,iv,salt); + return new BackupFileHeader(app, Jid.of(jid), timestamp, iv, salt); }