View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000373 | file | General | public | 2022-08-02 18:58 | 2022-10-09 18:53 |
Reporter | vismarli | Assigned To | christos | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | reopened | ||
Product Version | 5.34 | ||||
Fixed in Version | 5.43 | ||||
Summary | 0000373: only match first out of multiple magic files | ||||
Description | If we specify multiple magic files with "-m" and the file has matching from all of them, only the first magic with match will be evaluated, the rest will not be evaluated. for example, with "-m magicA:magicB:magicC" I observed the following: * if file has matching in magicA, magicB and magicC: only magicA will be evaluated * if file has matching in magicB and magicC : magicA and magicB will be evaluated, magicC won't be evaluated * if file has matching in magicC only : magicA, magicB and magicC will be evaluated not sure if this is expected behavior, from manual page it didn't mention any shortcut in evaluating multiple magic files nor any details of how multiple magic files will be evaluated. | ||||
Steps To Reproduce | $ cat magicA 0 search {\\rt1 RTF1.0 16 search ViVa2 Viva File 2.0 $ cat magicB 6 search ABCD ABCD File 10 search TesT Test File 1.0 $ xxd test-file-AB 0000000: 7b5c 7274 3120 4142 4344 5465 7354 2078 {\rt1 ABCDTesT x 0000010: 7856 6956 6132 xViVa2 $ file -km magicA test-file-AB test-file-AB: RTF1.0\012- Viva File 2.0, ASCII text, with no line terminators\012- data $ file -km magicB test-file-AB test-file-AB: ABCD File\012- Test File 1.0, ASCII text, with no line terminators\012- data $ file -km magicA:magicB test-file-AB test-file-AB: RTF1.0\012- Viva File 2.0, ASCII text, with no line terminators\012- data $ file -km magicB:magicA test-file-AB test-file-AB: ABCD File\012- Test File 1.0, ASCII text, with no line terminators\012- data | ||||
Additional Information | $ file -d -km magicA:magicB test-file-AB [try zmagic 0] [try tar 0] [try cdf 0] [try elf 0] [try softmagic 0] bb=[0x1f37280,22], 0 [b=0x1f37280,22], [o=0, c=0] mget(type=20, flag=0x40, offset=0, o=0, nbytes=22, il=0, nc=0) mget/96 @0: \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 1: > 0 search,={\rt1,"RTF1.0"] 0 == 0 = 1 bb=[0x1f37280,22], 16 [b=0x1f37280,22], [o=0x10, c=0] mget(type=20, flag=0x40, offset=16, o=0, nbytes=22, il=0, nc=0) mget/96 @16: \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 2: > 16 search,=ViVa2,"Viva File 2.0"] 0 == 0 = 1 [try ascmagic 1] test-file-AB: RTF1.0\012- Viva File 2.0, ASCII text, with no line terminators\012- data $ file -d -km magicB:magicA test-file-AB [try zmagic 0] [try tar 0] [try cdf 0] [try elf 0] [try softmagic 0] bb=[0x794280,22], 6 [b=0x794280,22], [o=0x6, c=0] mget(type=20, flag=0x40, offset=6, o=0, nbytes=22, il=0, nc=0) mget/96 @6: \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 1: > 6 search,=ABCD,"ABCD File"] 0 == 0 = 1 bb=[0x794280,22], 10 [b=0x794280,22], [o=0xa, c=0] mget(type=20, flag=0x40, offset=10, o=0, nbytes=22, il=0, nc=0) mget/96 @10: \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 2: > 10 search,=TesT,"Test File 1.0"] 0 == 0 = 1 [try ascmagic 1] test-file-AB: ABCD File\012- Test File 1.0, ASCII text, with no line terminators\012- data | ||||
Tags | No tags attached. | ||||
|
Intuitively if I specify multiple magic files e.g. "magicA:magicB", I expects libmagic to evaluate all rules from magicA+magicB combined/union-ed. But apparently its not that straightforward. Please tell me if its a bug or it's expected, can anyone clarify the behavior of multiple magic files via "-m" argument? |
|
Adding more clarifying information: * arguments to trigger this issue are: keep-going (-k) with multiple magic files specified in (-m) argument * the issue is always reproducible * this issue also occurs in latest version 5.42 |
|
Fixed, thanks! |
|
thanks christos for the update, I can see all rules from multiple files are now hits correctly, but the output separator is not correct. I got something like this from testing with multiple magic "magicB:magicA" : MagicB-Rule1\012- MagicB-Rule2MagicA-Rule1\012- MagicA-Rule2, ASCII text, with no line terminators the "MagicB-Rule2" supposed to be separated from "MagicA-Rule1". I believe the "firstline" flag in match() should not be initialized to 1, it should be based on "need_separator" and "printed_something" flags. |
|
Yup, fixed. |
|
looks great now, thank you christos. you can close this ticket. |
|
Verified fixed. |
Date Modified | Username | Field | Change |
---|---|---|---|
2022-08-02 18:58 | vismarli | New Issue | |
2022-08-03 01:04 | vismarli | Note Added: 0003796 | |
2022-08-16 14:40 | vismarli | Note Added: 0003797 | |
2022-08-17 08:45 | christos | Assigned To | => christos |
2022-08-17 08:45 | christos | Status | new => assigned |
2022-08-17 08:45 | christos | Status | assigned => resolved |
2022-08-17 08:45 | christos | Resolution | open => fixed |
2022-08-17 08:45 | christos | Fixed in Version | => 5.43 |
2022-08-17 08:45 | christos | Note Added: 0003798 | |
2022-08-17 16:03 | vismarli | Status | resolved => feedback |
2022-08-17 16:03 | vismarli | Resolution | fixed => reopened |
2022-08-17 16:03 | vismarli | Note Added: 0003801 | |
2022-08-18 07:58 | christos | Note Added: 0003804 | |
2022-08-18 17:27 | vismarli | Note Added: 0003807 | |
2022-08-18 17:27 | vismarli | Status | feedback => assigned |
2022-10-09 18:53 | christos | Status | assigned => resolved |
2022-10-09 18:53 | christos | Note Added: 0003831 |