[File] Negative indexing breaks search

Christos Zoulas christos at zoulas.com
Tue Oct 18 18:34:53 UTC 2022


It is not search that's broken. After the -4 offset the current file pointer is at

abcdefghijklmnopqrstuvwxyz
                                        ^
'x'.

so the search will start at xyz looking forward. You can view negative offsets as setting a new buffer starting point for the magic search.

christos

> On Oct 15, 2022, at 4:03 PM, Toni Ruottu <toni.ruottu at iki.fi> wrote:
> 
> I do not understand how negative indexing and search interact with each other. I created a file that contains a single line with alphabets from "a" to "z". It seems that after I have performed negative indexing, I can no longer search reliably.
> 
> 
> 
> The search in the following magic does not work.
> 
> 
> 
> 0       string          abc             abc
> >-4     string          xyz             xyz
> >0      search          opq             opq
> 
> 
> 
> 
> However, the search does work if I reverse the order.
> 
> 
> 0       string          abc             abc
> >0      search          opq             opq
> 
> >-4     string          xyz             xyz
> 
> 
> 
> Is this expected behaviour or have I encountered a bug?
> 
> 
> 
>   --Toni
> 
> 
> 
> 
> <broken_magic.DEFANGED-259><alphabet.DEFANGED-260>--
> File mailing list
> File at astron.com
> https://mailman.astron.com/mailman/listinfo/file
> <sanitizer.log>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.astron.com/pipermail/file/attachments/20221018/c75b86d4/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20221018/c75b86d4/attachment.asc>


More information about the File mailing list