View Issue Details

IDProjectCategoryView StatusLast Update
0000026file[All Projects] Generalpublic2018-12-10 21:12
ReporteranonymousAssigned Tochristos 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSKubuntuOS Version17.10
Product Version 
Target VersionFixed in VersionHEAD 
Summary0000026: Regex match does not capture all characters to end of line
DescriptionI've got an Ansible Vault data file that I'm making magic for; the second and subsequent lines of the example file should be irrelevant (for magic purposes), but I added placeholder lines (to match my actual file) for grins.

On the fourth line of my magic config file (the one that starts with ">>&1 regex/1l") my understanding is that "regex/1l" means that I'm specifying a regular expression, and that regex will be searched for in the block starting at the character following the previous match and ending at the end of the line. (It's this last bit, "...and ending at the end of the line", that I suspect is where my understanding is incomplete.)

HOWEVER, for some reason the last character of the line is getting chopped off; as you can see in the reproduction, file is only printing "AES25" in the output, rather than "AES256". This agrees with my testing, where if I try to match the regex "AES256" it fails, but matching "AES25" works.
Steps To Reproduce%) file --version
file-5.32
magic file from /home/alumin/.magic:/etc/magic:/usr/share/misc/magic

%) cat file-testfile
$ANSIBLE_VAULT;1.1;AES256
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000

%) cat dot-magic-notworking
## Ansible Vault files
0 string $ANSIBLE_VAULT Ansible Vault data
>&1 regex/1l ([0-9]+(\.[0-9]+)+) \b, version %s
>>&1 regex/1l .* \b, using %s encryption
!:mime application/ansible-vault
!:strength +60

%) cat dot-magic-working ## The only difference is changing "1l" to "2l" on line 4
## Ansible Vault files
0 string $ANSIBLE_VAULT Ansible Vault data
>&1 regex/1l ([0-9]+(\.[0-9]+)+) \b, version %s
>>&1 regex/2l .* \b, using %s encryption
!:mime application/ansible-vault
!:strength +60

%) file --magic-file dot-magic-notworking testfile
testfile: Ansible Vault data, version 1.1, using AES25 encryption

%) file --magic-file dot-magic-working testfile
testfile: Ansible Vault data, version 1.1, using AES256 encryption
Additional InformationThis testing is against version 5.32; apologies for not using the latest version, but it's what I have on my system and I'm kind of expecting this to be a problem with my magic file rather than a bug anyway, so I thought I might skip getting the latest version built and running unless it's necessary.

I've attached the three files in question; there's nothing special about them as far as I know, but I suppose you can't be too careful. :)
TagsNo tags attached.
Attach Tags

Activities

anonymous

2018-08-06 16:32

reporter  

file-testfile (1,845 bytes)
$ANSIBLE_VAULT;1.1;AES256
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000
file-testfile (1,845 bytes)
dot-magic-working (234 bytes)
## Ansible Vault files
0     string    $ANSIBLE_VAULT     Ansible Vault text
>&1   regex/1l  [0-9]+(\.[0-9]+)+  \b, version %s
>>&1  regex/2l  [^;]+$             \b, using %s encryption
!:mime application/ansible-vault
!:strength +60
dot-magic-working (234 bytes)
dot-magic-notworking (234 bytes)
## Ansible Vault files
0     string    $ANSIBLE_VAULT     Ansible Vault text
>&1   regex/1l  [0-9]+(\.[0-9]+)+  \b, version %s
>>&1  regex/1l  [^;]+$             \b, using %s encryption
!:mime application/ansible-vault
!:strength +60
dot-magic-notworking (234 bytes)

christos

2018-08-11 12:13

manager   ~0000048

Fixed on HEAD.

anonymous

2018-08-13 21:45

reporter   ~0000051

Cool, I assume you mean https://github.com/file/file/commit/b186b4a4ad8b4e6927bb7fd578db572d44bd0712 ? Thanks for looking into it!

christos

2018-12-10 21:12

manager   ~0000107

Verified fixed.

Issue History

Date Modified Username Field Change
2018-08-06 16:32 anonymous New Issue
2018-08-06 16:32 anonymous File Added: dot-magic-notworking
2018-08-06 16:32 anonymous File Added: dot-magic-working
2018-08-06 16:32 anonymous File Added: file-testfile
2018-08-11 12:12 christos Assigned To => christos
2018-08-11 12:12 christos Status new => assigned
2018-08-11 12:13 christos Status assigned => feedback
2018-08-11 12:13 christos Note Added: 0000048
2018-08-13 21:45 anonymous Note Added: 0000051
2018-12-10 21:12 christos Status feedback => resolved
2018-12-10 21:12 christos Resolution open => fixed
2018-12-10 21:12 christos Fixed in Version => HEAD
2018-12-10 21:12 christos Note Added: 0000107