mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 10:11:27 +00:00
work with number of bytes returned by ReadableFile.read(), Coverity issues 72259 and 72261
This commit is contained in:
@@ -47,10 +47,10 @@ class CiphertextReader implements Callable<Void> {
|
||||
int bytesRead = -1;
|
||||
do {
|
||||
ByteBuffer ciphertext = ByteBuffer.allocate(READ_BUFFER_SIZE);
|
||||
file.read(ciphertext);
|
||||
ciphertext.flip();
|
||||
bytesRead = ciphertext.remaining();
|
||||
bytesRead = file.read(ciphertext);
|
||||
if (bytesRead > 0) {
|
||||
ciphertext.flip();
|
||||
assert bytesRead == ciphertext.remaining();
|
||||
decryptor.append(ciphertext);
|
||||
}
|
||||
} while (bytesRead > 0);
|
||||
|
||||
@@ -43,7 +43,10 @@ class CryptoReadableFile implements ReadableFile {
|
||||
this.authenticate = authenticate;
|
||||
this.onAuthError = onAuthError;
|
||||
file.position(0);
|
||||
file.read(header);
|
||||
int headerBytesRead = file.read(header);
|
||||
if (headerBytesRead != header.capacity()) {
|
||||
throw new IllegalArgumentException("File too short to contain a header.");
|
||||
}
|
||||
header.flip();
|
||||
this.position(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user