Skip to content

Commit

Permalink
Add error handling for context.InputFile.Seek operation
Browse files Browse the repository at this point in the history
  • Loading branch information
vanbroup committed Jul 7, 2024
1 parent a0da987 commit 08b31dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sign/pdfxref.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ func (context *SignContext) writeXref() error {
}

func (context *SignContext) writeXrefTable() error {
// Seek to the start of the xref table
_, err := context.InputFile.Seek(context.PDFReader.XrefInformation.StartPos, 0)
if err != nil {
return fmt.Errorf("failed to seek to xref table: %w", err)
}

// Read the existing xref table
context.InputFile.Seek(context.PDFReader.XrefInformation.StartPos, 0)
xrefContent := make([]byte, context.PDFReader.XrefInformation.Length)
_, err := context.InputFile.Read(xrefContent)
_, err = context.InputFile.Read(xrefContent)
if err != nil {
return fmt.Errorf("failed to read xref table: %w", err)
}
Expand Down

0 comments on commit 08b31dc

Please sign in to comment.