polyfile icon indicating copy to clipboard operation
polyfile copied to clipboard

JPG file causes ValueError

Open richtea opened this issue 1 year ago • 0 comments

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

richtea avatar Oct 14 '24 11:10 richtea