Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPG file causes ValueError #3421

Open
richtea opened this issue Oct 14, 2024 · 0 comments
Open

JPG file causes ValueError #3421

richtea opened this issue Oct 14, 2024 · 0 comments

Comments

@richtea
Copy link

richtea commented Oct 14, 2024

Running the latest version under Ubuntu 22.04, certain specific JPG files cause a ValueError exception in magic.py line 2583:

            elif "%" in result_str.replace("%%", ""):
                result_str = result_str.replace("%lld", "%d")  # <- Apparent fixup for similar issue
                result_str = result_str % (result.value,)  # <- Error here

The error message is unsupported format character 'l' (0x6c) at index 20.

The trigger for this error is while handling a result_str containing the following format string: , at 16 reserved %#llx, which appears in magic_defs/database (although this is not the only location of the %#llx format string).

Given the line immediately preceding appears to be a fixup for a similar issue, the obvious fix is to add another fixup to replace %#llx with %x; however I'm not familiar with the format of the magic_defs database so maybe I'm missing something. If it is as simple as a new test, I'm happy to offer a PR. Note that there are occurrences of a similar but not identical format string %llx, which may cause the same issue (unable to repro with my dataset).

An example of a file that generates this error is attached.

Image

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

No branches or pull requests

1 participant