Fix possible username conflict in storage update.

This commit is contained in:
Greyson Parrelli
2023-03-24 16:32:38 -04:00
parent ba2d005b2a
commit b9b6a57e2c
2 changed files with 11 additions and 2 deletions

View File

@@ -981,6 +981,14 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
}
if (update.new.username != null) {
writableDatabase
.update(TABLE_NAME)
.values(USERNAME to null)
.where("$USERNAME = ?", update.new.username!!)
.run()
}
val updateCount = writableDatabase.update(TABLE_NAME, values, "$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeBytes(update.old.id.raw)))
if (updateCount < 1) {
throw AssertionError("Account update didn't match any rows!")