Skip to content

Commit df7e8b3

Browse files
committed
Do not crash on small files that start with the PE magic
1 parent 5da9140 commit df7e8b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

generate_sbom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ sub detect_mime {
205205
if ($first == 0xfeedface || $first == 0xfeedfacf || $first == 0xcefaedfe || $first == 0xcffaedfe) {
206206
return 'application/x-mach-binary';
207207
}
208-
if (($first & 0xffff0000) == 0x4d5a0000) {
208+
if (($first & 0xffff0000) == 0x4d5a0000 && length($prefix) >= 64) {
209209
my $o = unpack('@60V', $prefix);
210210
my $type = '';
211211
if (seek($fd, $o, 0) && read($fd, $type, 4) == 4 && unpack('N', $type) == 0x50450000) {

0 commit comments

Comments
 (0)