aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-08-29 21:55:10 +0200
committerJakob Unterwurzacher2016-09-25 16:43:17 +0200
commit1d62086742df25030869ccd4050eb9f89eb6661e (patch)
treed2b4df6d6044b37d214ba91ebf467313dbfc556d
parent9237b4f53e13075b595131f68edcfb2c831d684e (diff)
conentenc: handle zero-sized files in PlainSizeToCipherSize
Previously caused an integer underflow.
-rw-r--r--internal/contentenc/offsets.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/contentenc/offsets.go b/internal/contentenc/offsets.go
index ebafe9b..813a15f 100644
--- a/internal/contentenc/offsets.go
+++ b/internal/contentenc/offsets.go
@@ -28,8 +28,7 @@ func (be *ContentEnc) BlockNoToPlainOff(blockNo uint64) uint64 {
// PlainSize - calculate plaintext size from ciphertext size
func (be *ContentEnc) CipherSizeToPlainSize(cipherSize uint64) uint64 {
-
- // Zero sized files stay zero-sized
+ // Zero-sized files stay zero-sized
if cipherSize == 0 {
return 0
}
@@ -55,6 +54,10 @@ func (be *ContentEnc) CipherSizeToPlainSize(cipherSize uint64) uint64 {
// CipherSize - calculate ciphertext size from plaintext size
func (be *ContentEnc) PlainSizeToCipherSize(plainSize uint64) uint64 {
+ // Zero-sized files stay zero-sized
+ if plainSize == 0 {
+ return 0
+ }
// Block number at last byte
blockNo := be.PlainOffToBlockNo(plainSize - 1)