From e7ad0e296ef6f39e1586a417f9c1bc63673df233 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 17 Oct 2011 23:33:32 +0200 Subject: [PATCH] Validate account UUID on import --- .../fsck/k9/preferences/SettingsImporter.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/preferences/SettingsImporter.java b/src/com/fsck/k9/preferences/SettingsImporter.java index 82f95a886..05cdecc39 100644 --- a/src/com/fsck/k9/preferences/SettingsImporter.java +++ b/src/com/fsck/k9/preferences/SettingsImporter.java @@ -761,7 +761,9 @@ public class SettingsImporter { ImportedAccount account = parseAccount(xpp, accountUuids, overview); - if (!accounts.containsKey(account.uuid)) { + if (account == null) { + // Do nothing - parseAccount() already logged a message + } else if (!accounts.containsKey(account.uuid)) { accounts.put(account.uuid, account); } else { Log.w(K9.LOG_TAG, "Duplicate account entries with UUID " + account.uuid + @@ -781,9 +783,17 @@ public class SettingsImporter { boolean overview) throws XmlPullParserException, IOException { - ImportedAccount account = new ImportedAccount(); - String uuid = xpp.getAttributeValue(null, SettingsExporter.UUID_ATTRIBUTE); + + try { + UUID.fromString(uuid); + } catch (Exception e) { + skipToEndTag(xpp, SettingsExporter.ACCOUNT_ELEMENT); + Log.w(K9.LOG_TAG, "Skipping account with invalid UUID " + uuid); + return null; + } + + ImportedAccount account = new ImportedAccount(); account.uuid = uuid; if (overview || accountUuids.contains(uuid)) {