Skip to content

Commit

Permalink
Limit marc field terminator search to first 2048 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-vasile committed Dec 12, 2021
1 parent 222d00f commit 1c5174b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/magic/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ func Marc(raw []byte, limit uint32) bool {
}
}

// Field terminator is present.
return bytes.Contains(raw, []byte{0x1E})
l := 2048
if len(raw) < l {
l = len(raw)
}
// Field terminator is present in first 2048 bytes.
return bytes.Contains(raw[:l], []byte{0x1E})
}

0 comments on commit 1c5174b

Please sign in to comment.