From c9f4400e6dc71a36df5dc9725f52a8968f5f9803 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 10 Dec 2016 11:50:16 +0100 Subject: Replace all calls to naked panic() with log.Panic() We want all panics to show up in the syslog. --- internal/contentenc/content.go | 5 +++-- internal/contentenc/file_header.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'internal/contentenc') diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go index c42a844..322163a 100644 --- a/internal/contentenc/content.go +++ b/internal/contentenc/content.go @@ -6,6 +6,7 @@ import ( "encoding/binary" "encoding/hex" "errors" + "log" "github.com/rfjakob/gocryptfs/internal/cryptocore" "github.com/rfjakob/gocryptfs/internal/tlog" @@ -152,7 +153,7 @@ func (be *ContentEnc) EncryptBlock(plaintext []byte, blockNo uint64, fileID []by // This function can only be used in SIV mode. func (be *ContentEnc) EncryptBlockNonce(plaintext []byte, blockNo uint64, fileID []byte, nonce []byte) []byte { if be.cryptoCore.AEADBackend != cryptocore.BackendAESSIV { - panic("deterministic nonces are only secure in SIV mode") + log.Panic("deterministic nonces are only secure in SIV mode") } return be.doEncryptBlock(plaintext, blockNo, fileID, nonce) } @@ -166,7 +167,7 @@ func (be *ContentEnc) doEncryptBlock(plaintext []byte, blockNo uint64, fileID [] return plaintext } if len(nonce) != be.cryptoCore.IVLen { - panic("wrong nonce length") + log.Panic("wrong nonce length") } // Authenticate block with block number and file ID diff --git a/internal/contentenc/file_header.go b/internal/contentenc/file_header.go index 9ae5ae9..5c05818 100644 --- a/internal/contentenc/file_header.go +++ b/internal/contentenc/file_header.go @@ -7,6 +7,7 @@ package contentenc import ( "encoding/binary" "fmt" + "log" "github.com/rfjakob/gocryptfs/internal/cryptocore" ) @@ -30,7 +31,7 @@ type FileHeader struct { // Pack - serialize fileHeader object func (h *FileHeader) Pack() []byte { if len(h.ID) != headerIDLen || h.Version != CurrentVersion { - panic("FileHeader object not properly initialized") + log.Panic("FileHeader object not properly initialized") } buf := make([]byte, HeaderLen) binary.BigEndian.PutUint16(buf[0:headerVersionLen], h.Version) -- cgit v1.2.3