Package: file Version: 4.17-5 Severity: important I'm currently writing the magic specs for GEDCOM files, and while doing so I came across a bug in relative offsets when using search or regex matches.
According to man magic(5), when matching sublevels it is possible to specify an offset relative to the end of the previous level by prefixing the offset with &. Consider the following test case: -- gedfile.ged 0 HEAD 1 SOUR GENJ 2 VERS 2.x 2 NAME GenealogyJ 2 CORP Nils Meier 3 ADDR http://genj.sourceforge.net 1 DEST ANY 1 DATE 15 JAN 2007 2 TIME 17:07:35 1 SUBM @SUB1@ 1 FILE bilotta.ged 1 GEDC 2 VERS 5.5 2 FORM Lineage-Linked 1 CHAR UNICODE 1 LANG Italian -- and the following magic spec: -- /etc/magic # GEDCOM Geneaolgy file 0 string/c 0\ HEAD GEDCOM genealogy data >&0 search 1\ GEDC >>&0 search 2\ VERS version >>>&1 string >\0 %s -- The expected result, when running file gedfile.ged, would be an identification of: GEDCOM genealogy data version 5.5 Instead, the result is: GEDCOM genealogy data version 2 VERS 2.x So, the first search, although successful (the branch is being taken) is not moving the relative pointer, and thus the second match finds the first VERS line instead of the second one; likewise, the second search is not moving the relative pointer either because the string found on the last level is the whole VERS line and not just what's after "2 VERS". Similar results are obtained when using regex instead of search. I noticed that the latest upstream version of file as available from ftp://ftp.astron.com/pub/file/ is 4.19. However, I have not tested if the bug is still present in the new upstream version or not. -- System Information: Debian Release: 4.0 APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.18-3-686 Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8) Versions of packages file depends on: ii libc6 2.3.6.ds1-10 GNU C Library: Shared libraries ii libmagic1 4.17-5 File type determination library us file recommends no packages. -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]