EncFSInputStream.read() result should be positive
According to java.io.InputStream spec read() needs to normalize the value of the returned byte to be between 0-255. Fixes mrpdaemon/encfs-java#57
This commit is contained in:
parent
5f477a9aee
commit
489f3f607a
1 changed files with 6 additions and 6 deletions
|
@ -128,9 +128,9 @@ public class EncFSInputStream extends FilterInputStream {
|
|||
byte[] oneByte = new byte[1];
|
||||
int ret = this.read(oneByte, 0, 1);
|
||||
if (ret == 1) {
|
||||
return oneByte[0];
|
||||
return oneByte[0] & 0xFF;
|
||||
}
|
||||
return ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -288,8 +288,8 @@ public class EncFSInputStream extends FilterInputStream {
|
|||
if (zeroBlock) {
|
||||
blockBuf = cipherBuf;
|
||||
} else {
|
||||
blockBuf = BlockCrypto.blockDecrypt(volume,
|
||||
getBlockIV(), cipherBuf);
|
||||
blockBuf = BlockCrypto.blockDecrypt(volume, getBlockIV(),
|
||||
cipherBuf);
|
||||
}
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -303,8 +303,8 @@ public class EncFSInputStream extends FilterInputStream {
|
|||
blockNum++;
|
||||
} else if (bytesRead > 0) { // stream decode
|
||||
try {
|
||||
blockBuf = StreamCrypto.streamDecrypt(volume,
|
||||
getBlockIV(), cipherBuf, 0, bytesRead);
|
||||
blockBuf = StreamCrypto.streamDecrypt(volume, getBlockIV(),
|
||||
cipherBuf, 0, bytesRead);
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue