Skip to content

Commit

Permalink
Add safety check for invalid font obfuscation key (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolatkey authored Oct 9, 2024
1 parent 6d349b9 commit 6c772de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/parser/epub/deobfuscator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6c772de

Please sign in to comment.