mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-07-29 00:59:26 +00:00
Prevent invalid profile keys from being processed for storage service
This commit is contained in:
parent
06fd350e9c
commit
7b08225c57
@ -172,6 +172,10 @@ public class ContactRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
||||
e164 = firstNonEmpty(remote.e164, local.e164);
|
||||
}
|
||||
|
||||
final var remoteProfileKey = remote.profileKey.size() == 0
|
||||
|| KeyUtils.profileKeyOrNull(remote.profileKey.toByteArray()) == null
|
||||
? ByteString.EMPTY
|
||||
: remote.profileKey;
|
||||
final var mergedBuilder = remote.newBuilder()
|
||||
.aci(local.aci.isEmpty() ? remote.aci : local.aci)
|
||||
.e164(e164)
|
||||
@ -181,7 +185,7 @@ public class ContactRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
||||
.systemGivenName(account.isPrimaryDevice() ? local.systemGivenName : remote.systemGivenName)
|
||||
.systemFamilyName(account.isPrimaryDevice() ? local.systemFamilyName : remote.systemFamilyName)
|
||||
.systemNickname(remote.systemNickname)
|
||||
.profileKey(firstNonEmpty(remote.profileKey, local.profileKey))
|
||||
.profileKey(firstNonEmpty(remoteProfileKey, local.profileKey))
|
||||
.username(firstNonEmpty(remote.username, local.username))
|
||||
.identityState(identityState)
|
||||
.identityKey(identityKey)
|
||||
|
||||
@ -96,6 +96,17 @@ public class KeyUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static ProfileKey profileKeyOrNull(byte[] profileKey) {
|
||||
if (profileKey == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new ProfileKey(profileKey);
|
||||
} catch (InvalidInputException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String createPassword() {
|
||||
return getSecret(18);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user