profileKey: Check length of incoming values, clear on failed send/fetch

This commit is contained in:
Scott Nonnenberg 2022-02-22 12:34:57 -08:00 committed by GitHub
parent b96c7e90fe
commit b33b5d2a30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 284 additions and 56 deletions

View file

@ -4624,7 +4624,7 @@ export class ConversationModel extends window.Backbone
}
async setProfileKey(
profileKey: string,
profileKey: string | undefined,
{ viaStorageServiceSync = false } = {}
): Promise<void> {
// profileKey is a string so we can compare it directly
@ -4643,7 +4643,10 @@ export class ConversationModel extends window.Backbone
sealedSender: SEALED_SENDER.UNKNOWN,
});
if (!viaStorageServiceSync) {
// If our profile key was cleared above, we don't tell our linked devices about it.
// We want linked devices to tell us what it should be, instead of telling them to
// erase their local value.
if (!viaStorageServiceSync && profileKey) {
this.captureChange('profileKey');
}
@ -4686,6 +4689,12 @@ export class ConversationModel extends window.Backbone
profileKey,
uuid
);
if (!profileKeyVersion) {
log.warn(
'deriveProfileKeyVersionIfNeeded: Failed to derive profile key version, clearing profile key.'
);
this.setProfileKey(undefined);
}
this.set({ profileKeyVersion });
}