Skip to content

Commit

Permalink
Checks on stated byte lengths in xref stream objects. Closes #94.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunnsteinn Hall authored and Gunnsteinn Hall committed Aug 2, 2017
1 parent 28aea0d commit 2ecf2ac
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pdf/core/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,15 @@ func (this *PdfParser) parseXrefStream(xstm *PdfObjectInteger) (*PdfObjectDictio
s2 := int(b[0] + b[1] + b[2])
deltab := int(b[0] + b[1] + b[2])

if s0 < 0 || s1 < 0 || s2 < 0 {
common.Log.Debug("Error s value < 0 (%d,%d,%d)", s0, s1, s2)
return nil, errors.New("Range check error")
}
if deltab == 0 {
common.Log.Debug("No xref objects in stream (deltab == 0)")
return trailerDict, nil
}

// Calculate expected entries.
entries := len(ds) / deltab

Expand Down

0 comments on commit 2ecf2ac

Please sign in to comment.