[ https://issues.apache.org/jira/browse/TIKA-4309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17890184#comment-17890184 ]
ASF GitHub Bot commented on TIKA-4309: -------------------------------------- tballison commented on code in PR #1993: URL: https://github.com/apache/tika/pull/1993#discussion_r1803484128 ########## tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-code-module/src/main/java/org/apache/tika/parser/executable/UniversalExecutableParser.java: ########## @@ -119,46 +118,62 @@ public void parseMachO(XHTMLContentHandler xhtml, EmbeddedDocumentExtractor extr if (!unsortedOffsets && archIndex > 0 && offset < (long) offsetAndSizePerArch[archIndex - 1].getLeft()) { unsortedOffsets = true; } - var size = is64 + long size = is64 ? (isLE ? EndianUtils.readLongLE(stream) : EndianUtils.readLongBE(stream)) : (isLE ? EndianUtils.readIntLE(stream) : EndianUtils.readIntBE(stream)); offsetAndSizePerArch[archIndex] = Pair.of(offset, size); if (is64) { - if (stream.skip(8) != 8) { - throw new TikaException("Failed to skip align and reserved"); - } + IOUtils.skipFully(stream, 8); } else { - if (stream.skip(4) != 4) { - throw new TikaException("Failed to skip align"); - } + IOUtils.skipFully(stream, 4); } currentOffset += archStructSize; } if (unsortedOffsets) { - Arrays.sort(offsetAndSizePerArch, Comparator.comparingLong(entry -> (long) entry.getLeft())); + Arrays.sort(offsetAndSizePerArch, Comparator.comparingLong(Pair::getLeft)); } - for (var archIndex = 0; archIndex < archsCount; archIndex++) { - var skipUntilStart = (long) offsetAndSizePerArch[archIndex].getLeft() - currentOffset; - if (stream.skip(skipUntilStart) != skipUntilStart) { - throw new TikaException("Failed to skip to the start of the per-architecture Mach-O"); - } + for (int archIndex = 0; archIndex < archsCount; archIndex++) { + long skipUntilStart = offsetAndSizePerArch[archIndex].getLeft() - currentOffset; + IOUtils.skipFully(stream, skipUntilStart); currentOffset += skipUntilStart; - var perArchMachO = new byte[(int) (long) offsetAndSizePerArch[archIndex].getRight()]; - if (stream.read(perArchMachO) != perArchMachO.length) { - throw new TikaException("Failed to read the per-architecture Mach-O"); - } + //TODO > ExecutableParser: support MachO > ------------------------------- > > Key: TIKA-4309 > URL: https://issues.apache.org/jira/browse/TIKA-4309 > Project: Tika > Issue Type: New Feature > Reporter: Alexey Pelykh > Priority: Major > -- This message was sent by Atlassian Jira (v8.20.10#820010)