[omemo] Sanitize BLOBs in secret table
This commit is contained in:
@@ -147,7 +147,7 @@ class LiteAxolotlStore(AxolotlStore):
|
|||||||
create_db_sql = """
|
create_db_sql = """
|
||||||
BEGIN TRANSACTION;
|
BEGIN TRANSACTION;
|
||||||
%s
|
%s
|
||||||
PRAGMA user_version=8;
|
PRAGMA user_version=9;
|
||||||
END TRANSACTION;
|
END TRANSACTION;
|
||||||
""" % (create_tables)
|
""" % (create_tables)
|
||||||
self._con.executescript(create_db_sql)
|
self._con.executescript(create_db_sql)
|
||||||
@@ -278,6 +278,27 @@ class LiteAxolotlStore(AxolotlStore):
|
|||||||
self._con.execute('PRAGMA user_version=8')
|
self._con.execute('PRAGMA user_version=8')
|
||||||
self._con.commit()
|
self._con.commit()
|
||||||
|
|
||||||
|
if self.user_version() < 9:
|
||||||
|
# Sanitize invalid BLOBs from the python2 days
|
||||||
|
query_keys = '''SELECT device_id,
|
||||||
|
CAST(public_key as BLOB) as public_key,
|
||||||
|
CAST(private_key as BLOB) as private_key
|
||||||
|
FROM secret'''
|
||||||
|
rows = self._con.execute(query_keys).fetchall()
|
||||||
|
|
||||||
|
delete = 'DELETE FROM secret'
|
||||||
|
self._con.execute(delete)
|
||||||
|
|
||||||
|
insert = '''INSERT INTO secret (device_id, public_key, private_key)
|
||||||
|
VALUES (?, ?, ?)'''
|
||||||
|
for row in rows:
|
||||||
|
try:
|
||||||
|
self._con.execute(insert, row)
|
||||||
|
except Exception as error:
|
||||||
|
self._log.warning(error)
|
||||||
|
self._con.execute('PRAGMA user_version=9')
|
||||||
|
self._con.commit()
|
||||||
|
|
||||||
def loadSignedPreKey(self, signedPreKeyId):
|
def loadSignedPreKey(self, signedPreKeyId):
|
||||||
query = 'SELECT record FROM signed_prekeys WHERE prekey_id = ?'
|
query = 'SELECT record FROM signed_prekeys WHERE prekey_id = ?'
|
||||||
result = self._con.execute(query, (signedPreKeyId, )).fetchone()
|
result = self._con.execute(query, (signedPreKeyId, )).fetchone()
|
||||||
|
|||||||
Reference in New Issue
Block a user