diff --git a/src/p_armpe.cpp b/src/p_armpe.cpp index 801b32c7..6bbe195c 100644 --- a/src/p_armpe.cpp +++ b/src/p_armpe.cpp @@ -1764,6 +1764,12 @@ void PackArmPe::pack(OutputFile *fo) ft.addvalue = ih.codebase - rvamin; // compress int strategy = allow_filter ? 0 : -3; + // disable filters for files with broken headers + if (ih.codebase + ih.codesize > ph.u_len) + { + ft.buf_len = 1; + strategy = -3; + } compressWithFilters(&ft, 2048, strategy, NULL, 0, 0, ih.codebase, rvamin); // info: see buildLoader() diff --git a/src/p_w32pe.cpp b/src/p_w32pe.cpp index 50510d4a..fcd4147a 100644 --- a/src/p_w32pe.cpp +++ b/src/p_w32pe.cpp @@ -1853,6 +1853,14 @@ void PackW32Pe::pack(OutputFile *fo) ft.addvalue = ih.codebase - rvamin; // compress int strategy = allow_filter ? 0 : -3; + + // disable filters for files with broken headers + if (ih.codebase + ih.codesize > ph.u_len) + { + ft.buf_len = 1; + strategy = -3; + } + compressWithFilters(&ft, 2048, strategy, NULL, 0, 0, ih.codebase, rvamin); // info: see buildLoader()