Skip to content

FileFunctions: bail out when wxZipInputStream stalls on a bad entry - #553

Merged
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:fix/ipfilter-zip-malformed-spin
May 11, 2026
Merged

FileFunctions: bail out when wxZipInputStream stalls on a bad entry#553
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:fix/ipfilter-zip-malformed-spin

Conversation

@got3nks

@got3nks got3nks commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #376 ("Error: unsupported Zip compression method"). On 2024-08-04 the eMule-security IPFilter feed published a malformed ipfilter.zip and every daemon that auto-fetched it spun in an infinite log loop, filling logs with gigabytes of Error: unsupported Zip compression method per minute until disk filled or the operator killed the process. The upstream feed has since been fixed, but nothing in our code prevents the next bad zip from doing the same.

Root cause

UnpackZipFile() in src/libs/common/FileFunctions.cpp reads each interesting entry with:

while (!zip.Eof()) {
    zip.Read(buffer, sizeof(buffer));
    target.Write(buffer, zip.LastRead());
}

When wxZipInputStream encounters an unsupported compression method (or any other entry-level decompression error), Read() emits one wxLogError, returns zero bytes, and parks the stream in an error state — but Eof() keeps returning false. The loop then spins forever, re-emitting the wx error on every iteration.

Fix

Break the inner loop when Read() returns zero bytes. The wx error still surfaces exactly once so the operator sees what failed; target.Length() stays 0; UnpackZipFile returns false; UnpackArchive returns EFT_Error; the existing IPFilter::Reload caller logs Failed to load ipfilter.dat file '...', unknown format encountered. and abandons the file. Next IPFilter fetch picks up a clean copy as before.

Verification

Standalone reproduction on Ubuntu 26.04 ARM64, libwx 3.2 — built a hand-crafted zip with one entry using compression method 0xff:

original loop:  50+ iterations of "Error: unsupported Zip compression method"
                (capped at 50 by the test harness; production would run unbounded)
fixed loop:     1 iteration, single error message, clean exit

Then compile-tested FileFunctions.cpp clean against the project's exact flags.

Closes #376

UnpackZipFile() reads each interesting zip entry with

    while (!zip.Eof()) {
        zip.Read(buffer, sizeof(buffer));
        target.Write(buffer, zip.LastRead());
    }

When wxZipInputStream encounters an unsupported compression method
(or any other entry-level decompression error), Read() emits one
'Error: unsupported Zip compression method' wxLogError, returns
zero bytes, and leaves the stream in an error state -- but Eof()
keeps returning false. The loop then spins forever, re-emitting
the wx error on every iteration. Reproduced standalone with a
hand-crafted zip whose entry uses compression method 0xff: 50
iterations to reach the test cap, would have run unbounded.

amule-project#376 was a malformed (or just newer-method) eMule-security
ipfilter.zip on 2024-08-04. Affected daemons logged gigabytes of
identical error lines per minute until disk filled or the user
killed the process. Multiple users reported it within a day, then
the upstream feed got fixed and the symptom went away -- but
nothing prevents the next bad zip from doing the same.

Break the inner loop when Read() returns zero bytes. The wx error
still surfaces exactly once (so the operator sees what failed); no
target data was written so target.Length() is 0; UnpackZipFile
returns false; UnpackArchive returns EFT_Error; the IPFilter
reload caller logs its own 'Failed to load ipfilter.dat ...
unknown format encountered.' and abandons the file. Next IPFilter
fetch picks up a clean copy as before.

Verified on Ubuntu 26.04 ARM64, libwx 3.2:

  original loop, hand-crafted bad zip: 50+ iterations
  fixed loop:                          1 iteration, clean exit

Closes amule-project#376
@mrjimenez
mrjimenez merged commit 9021dec into amule-project:master May 11, 2026
12 checks passed
@got3nks
got3nks deleted the fix/ipfilter-zip-malformed-spin branch May 11, 2026 08:01
got3nks added a commit to got3nks/amule that referenced this pull request Jul 23, 2026
)

The it_CH catalog file was removed in amule-project#552, but the surrounding
references were left behind: the LINGUAS entry, the po/CMakeLists.txt
language label, the redundant [it_CH] .desktop keys (identical to
[it]), and the it_CH -> ITALIAN mapping in the Windows NSIS generator.

None affect the build (it is glob-driven and it_CH.po is already gone),
but they point at a catalog that no longer exists. Remove them so the
tree is consistent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: unsupported Zip compression method

2 participants