Skip to content

Commit

Permalink
'#2234: add a comment to warn collaborators about stream.readAllBytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed Jul 5, 2024
1 parent 572f9d2 commit 2d608bd
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ public void parse(InputStream stream, ContentHandler handler, Metadata metadata,
metadata.set(HttpHeaders.CONTENT_TYPE, RESUME_DAT_ENTRY_MIME_TYPE);
metadata.remove(TikaCoreProperties.RESOURCE_NAME_KEY);

// Generally stream.readAllBytes() is not safe and should be avoided because it
// may cause OOME with large misdetected files. But in this specific case, just
// carved resume.dat entries, limited to 32KB by the carving configuration, are
// handled by this parser.
byte[] bytes = stream.readAllBytes();

char[] prev = "d1:X1:0".toCharArray();
byte[] in = new byte[prev.length + bytes.length];
for (int i = 0; i < prev.length; i++) {
Expand Down

0 comments on commit 2d608bd

Please sign in to comment.