conentenc: handle zero-sized files in PlainSizeToCipherSize
Previously caused an integer underflow.
This commit is contained in:
parent
9237b4f53e
commit
1d62086742
@ -28,8 +28,7 @@ func (be *ContentEnc) BlockNoToPlainOff(blockNo uint64) uint64 {
|
|||||||
|
|
||||||
// PlainSize - calculate plaintext size from ciphertext size
|
// PlainSize - calculate plaintext size from ciphertext size
|
||||||
func (be *ContentEnc) CipherSizeToPlainSize(cipherSize uint64) uint64 {
|
func (be *ContentEnc) CipherSizeToPlainSize(cipherSize uint64) uint64 {
|
||||||
|
// Zero-sized files stay zero-sized
|
||||||
// Zero sized files stay zero-sized
|
|
||||||
if cipherSize == 0 {
|
if cipherSize == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -55,6 +54,10 @@ func (be *ContentEnc) CipherSizeToPlainSize(cipherSize uint64) uint64 {
|
|||||||
|
|
||||||
// CipherSize - calculate ciphertext size from plaintext size
|
// CipherSize - calculate ciphertext size from plaintext size
|
||||||
func (be *ContentEnc) PlainSizeToCipherSize(plainSize uint64) uint64 {
|
func (be *ContentEnc) PlainSizeToCipherSize(plainSize uint64) uint64 {
|
||||||
|
// Zero-sized files stay zero-sized
|
||||||
|
if plainSize == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// Block number at last byte
|
// Block number at last byte
|
||||||
blockNo := be.PlainOffToBlockNo(plainSize - 1)
|
blockNo := be.PlainOffToBlockNo(plainSize - 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user