From c40df50f69594702ad102ea9c0a14fa3e5902c32 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 3 Oct 2024 00:42:17 -0700 Subject: [PATCH] add safety check for 0-length obfuscationKey --- pkg/parser/epub/deobfuscator.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/parser/epub/deobfuscator.go b/pkg/parser/epub/deobfuscator.go index 1128f21c..fe766b29 100644 --- a/pkg/parser/epub/deobfuscator.go +++ b/pkg/parser/epub/deobfuscator.go @@ -119,6 +119,12 @@ func (d DeobfuscatingResource) Stream(w io.Writer, start int64, end int64) (int6 shasum := sha1.Sum([]byte(d.identifier)) obfuscationKey = shasum[:] } + + // If getHashKeyAdobe() is blank, meaning the hex decoding of the UUID failed + if len(obfuscationKey) == 0 { + return 0, fetcher.Other(errors.New("error deriving font deobfuscation key")) + } + deobfuscateFont(obfuscatedPortion, start, obfuscationKey, v) defer pr.Close()