Skip to content

Increase UPX_RSIZE_MAX for commands -l (list), -t (test), -d (de-compress) #867

@jreiser

Description

@jreiser

What's the problem (or question)?

In src/conf.h, the compile-time constant UPX_RSIZE_MAX is too conservative for the UPX commands -l (list), -t (test), and -d (de-compress). The current limit of 768 MiB (768 * 1024 * 1024) is based on estimated memory space required during worst-case compression (factor of 9/8 expansion on two copies of the input file) while running on 32-bit Microsoft Windows, where the operating system allows a maximum of 2 GiB for a user-mode process. While 768 MiB is nice for compression, it is too low for the commands -l (list), -t (test), and -d (de-compress) when applied to files which have been compressed using UPX source which has been modified and run on a 64-bit machine. Already there have been compressed files of 874 MiB and 936 MiB created by application developers with the partial intent to hinder offline de-compression. The -l, -t, and -d commands can operate in less space; one initial estimate is 9/8 of the input size, so that for these commands, then UPX_RSIZE_MAX of about 1.5 GIB would suffice, even on 32-bit Windows.

[Note that many data fields are 32 bits, both for internal use by UPX and for external file formats such as PE ("Portable Executable" of Wndows). Expanding beyond 4GiB would require large effort, even if the de-compression time for such a large file were acceptable.]

What should have happened?

Commands -l (list), -t (test) and -d (de-compress) should work with files up to 1.5 GiB in size, if otherwise conforming to UPX format.

Do you have an idea for a solution?

Separate the tests in src/util/util.cpp and src/work.cpp to allow larger files for commands -l, -t, and -d.

How can we reproduce the issue?

Please tell us details about your environment.

  • UPX version used (upx --version):upx-4.2.4
  • Host Operating System and version: Linux 6.x
  • Host CPU architecture: x86_64
  • Target Operating System and version: Linux 6.x
  • Target CPU architecture: x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions