Add check for ID array length

This commit is contained in:
Gunnsteinn Hall 2017-07-23 12:30:21 +00:00
parent 9ff2413609
commit 3639b5c279

View File

@ -292,7 +292,7 @@ func PdfCryptMakeNew(parser *PdfParser, ed, trailer *PdfObjectDictionary) (PdfCr
// Strictly, if file is encrypted, the ID should always be specified
// but clearly not everyone is following the specification.
id0 := PdfObjectString("")
if idArray, ok := trailer.Get("ID").(*PdfObjectArray); ok {
if idArray, ok := trailer.Get("ID").(*PdfObjectArray); ok && len(*idArray) >= 1 {
id0obj, ok := (*idArray)[0].(*PdfObjectString)
if !ok {
return crypter, errors.New("Invalid trailer ID")