Fix attachment pointer crash when missing incremental digest.
This commit is contained in:
parent
f5fc2acf50
commit
8c1f2c6064
4 changed files with 9 additions and 7 deletions
|
@ -113,7 +113,7 @@ public class PointerAttachment extends Attachment {
|
|||
pointer.get().asPointer().getRemoteId().toString(),
|
||||
encodedKey, null,
|
||||
pointer.get().asPointer().getDigest().orElse(null),
|
||||
pointer.get().asPointer().getincrementalDigest().orElse(null),
|
||||
pointer.get().asPointer().getIncrementalDigest().orElse(null),
|
||||
fastPreflightId,
|
||||
pointer.get().asPointer().getVoiceNote(),
|
||||
pointer.get().asPointer().isBorderless(),
|
||||
|
@ -139,7 +139,7 @@ public class PointerAttachment extends Attachment {
|
|||
thumbnail != null && thumbnail.asPointer().getKey() != null ? Base64.encodeBytes(thumbnail.asPointer().getKey()) : null,
|
||||
null,
|
||||
thumbnail != null ? thumbnail.asPointer().getDigest().orElse(null) : null,
|
||||
thumbnail != null ? thumbnail.asPointer().getincrementalDigest().orElse(null) : null,
|
||||
thumbnail != null ? thumbnail.asPointer().getIncrementalDigest().orElse(null) : null,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
|
@ -169,7 +169,7 @@ public class PointerAttachment extends Attachment {
|
|||
thumbnail != null && thumbnail.asPointer().getKey() != null ? Base64.encodeBytes(thumbnail.asPointer().getKey()) : null,
|
||||
null,
|
||||
thumbnail != null ? thumbnail.asPointer().getDigest().orElse(null) : null,
|
||||
thumbnail != null ? thumbnail.asPointer().getincrementalDigest().orElse(null) : null,
|
||||
thumbnail != null ? thumbnail.asPointer().getIncrementalDigest().orElse(null) : null,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.whispersystems.signalservice.internal.util.concurrent.FutureTransform
|
|||
import org.whispersystems.signalservice.internal.util.concurrent.ListenableFuture;
|
||||
import org.whispersystems.signalservice.internal.websocket.ResponseMapper;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -154,7 +153,7 @@ public class SignalServiceMessageReceiver {
|
|||
if (!pointer.getDigest().isPresent()) throw new InvalidMessageException("No attachment digest!");
|
||||
|
||||
socket.retrieveAttachment(pointer.getCdnNumber(), pointer.getRemoteId(), destination, maxSizeBytes, listener);
|
||||
return AttachmentCipherInputStream.createForAttachment(destination, pointer.getSize().orElse(0), pointer.getKey(), pointer.getDigest().get(), pointer.getincrementalDigest().orElse(new byte[0]));
|
||||
return AttachmentCipherInputStream.createForAttachment(destination, pointer.getSize().orElse(0), pointer.getKey(), pointer.getDigest().get(), pointer.getIncrementalDigest().orElse(new byte[0]));
|
||||
}
|
||||
|
||||
public InputStream retrieveSticker(byte[] packId, byte[] packKey, int stickerId)
|
||||
|
|
|
@ -111,7 +111,7 @@ public class SignalServiceAttachmentPointer extends SignalServiceAttachment {
|
|||
return digest;
|
||||
}
|
||||
|
||||
public Optional<byte[]> getincrementalDigest() {
|
||||
public Optional<byte[]> getIncrementalDigest() {
|
||||
return incrementalDigest;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,10 +42,13 @@ public final class AttachmentPointerUtil {
|
|||
.setContentType(attachment.getContentType())
|
||||
.setKey(ByteString.copyFrom(attachment.getKey()))
|
||||
.setDigest(ByteString.copyFrom(attachment.getDigest().get()))
|
||||
.setIncrementalDigest(ByteString.copyFrom(attachment.getincrementalDigest().get()))
|
||||
.setSize(attachment.getSize().get())
|
||||
.setUploadTimestamp(attachment.getUploadTimestamp());
|
||||
|
||||
if (attachment.getIncrementalDigest().isPresent()) {
|
||||
builder.setIncrementalDigest(ByteString.copyFrom(attachment.getIncrementalDigest().get()));
|
||||
}
|
||||
|
||||
if (attachment.getRemoteId().getV2().isPresent()) {
|
||||
builder.setCdnId(attachment.getRemoteId().getV2().get());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue