Prevent database downgrade (OKC-01-012)
This commit is contained in:
@@ -54,7 +54,7 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class KeychainDatabase extends SQLiteOpenHelper {
|
public class KeychainDatabase extends SQLiteOpenHelper {
|
||||||
private static final String DATABASE_NAME = "openkeychain.db";
|
private static final String DATABASE_NAME = "openkeychain.db";
|
||||||
private static final int DATABASE_VERSION = 12;
|
private static final int DATABASE_VERSION = 13;
|
||||||
static Boolean apgHack = false;
|
static Boolean apgHack = false;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@@ -296,6 +296,8 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
|||||||
// the api_accounts fix and the new update keys table
|
// the api_accounts fix and the new update keys table
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case 13:
|
||||||
|
// do nothing here, just consolidate
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,6 +308,13 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
|||||||
mContext.getApplicationContext().startActivity(consolidateIntent);
|
mContext.getApplicationContext().startActivity(consolidateIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
// NOTE: downgrading the database is explicitly not allowed to prevent
|
||||||
|
// someone from exploiting old bugs to export the database
|
||||||
|
throw new RuntimeException("Downgrading the database is not allowed!");
|
||||||
|
}
|
||||||
|
|
||||||
/** This method tries to import data from a provided database.
|
/** This method tries to import data from a provided database.
|
||||||
*
|
*
|
||||||
* The sole assumptions made on this db are that there is a key_rings table
|
* The sole assumptions made on this db are that there is a key_rings table
|
||||||
|
|||||||
Reference in New Issue
Block a user