From 179471b6486b2cb3e6e24eed1d9f86f2e880e334 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 17 Feb 2019 17:13:20 +0100 Subject: ParseHeader: print hexdump on error Should help debugging https://github.com/rfjakob/gocryptfs/issues/363 --- internal/contentenc/file_header.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'internal') diff --git a/internal/contentenc/file_header.go b/internal/contentenc/file_header.go index 62d24cb..5f8bd63 100644 --- a/internal/contentenc/file_header.go +++ b/internal/contentenc/file_header.go @@ -7,6 +7,7 @@ package contentenc import ( "bytes" "encoding/binary" + "encoding/hex" "fmt" "log" @@ -52,11 +53,13 @@ func ParseHeader(buf []byte) (*FileHeader, error) { var h FileHeader h.Version = binary.BigEndian.Uint16(buf[0:headerVersionLen]) if h.Version != CurrentVersion { - return nil, fmt.Errorf("ParseHeader: invalid version, want=%d have=%d", CurrentVersion, h.Version) + return nil, fmt.Errorf("ParseHeader: invalid version, want=%d have=%d. Hexdump: %s", + CurrentVersion, h.Version, hex.EncodeToString(buf)) } h.ID = buf[headerVersionLen:] if bytes.Equal(h.ID, allZeroFileID) { - return nil, fmt.Errorf("ParseHeader: file id is all-zero") + return nil, fmt.Errorf("ParseHeader: file id is all-zero. Hexdump: %s", + hex.EncodeToString(buf)) } return &h, nil } -- cgit v1.2.3