Skip to content

Commit

Permalink
Fail with exception when decoding invalid image message (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchof committed Oct 12, 2021
1 parent 47048cb commit e36aa35
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
8 changes: 0 additions & 8 deletions src/main/java/com/mountainminds/three4j/BlobId.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
*******************************************************************************/
package com.mountainminds.three4j;

import java.io.IOException;
import java.io.InputStream;

/**
* A 16 byte identifier for uploaded blobs.
*/
Expand Down Expand Up @@ -46,9 +43,4 @@ public static BlobId of(String hexvalue) {
return of(fromHex(hexvalue));
}

static BlobId read(InputStream in) throws IOException {
var id = in.readNBytes(SIZE);
return id.length == SIZE ? of(id) : null;
}

}
8 changes: 0 additions & 8 deletions src/main/java/com/mountainminds/three4j/Nonce.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
*******************************************************************************/
package com.mountainminds.three4j;

import java.io.IOException;
import java.io.InputStream;

import software.pando.crypto.nacl.Bytes;

/**
Expand Down Expand Up @@ -55,9 +52,4 @@ public static Nonce random() {
return of(Bytes.secureRandom(SIZE));
}

static Nonce read(InputStream in) throws IOException {
var id = in.readNBytes(SIZE);
return id.length == SIZE ? of(id) : null;
}

}
4 changes: 2 additions & 2 deletions src/main/java/com/mountainminds/three4j/PlainMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public final static class Image extends PlainMessage {
private final Nonce nonce;

private Image(DataInputStream in) throws IOException {
blobId = BlobId.read(in);
blobId = BlobId.of(in.readNBytes(BlobId.SIZE));
size = in.readInt();
nonce = Nonce.read(in);
nonce = Nonce.of(in.readNBytes(Nonce.SIZE));
}

public Image(UploadedBlob blob) throws IllegalArgumentException {
Expand Down

0 comments on commit e36aa35

Please sign in to comment.