[vim/vim] xxd enters infinite loop with some inputs (#5272)

16 views
Skip to first unread message

aslvim

unread,
Nov 27, 2019, 12:25:07 AM11/27/19
to vim/vim, Subscribed

xxd -r hits an infinite loop for some inputs:

for example, echo -en '41414141\n\n' | xxd -r will run forever, spinning.

Environment:

xxd V1.10 27oct98 by Juergen Weigert
VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 7 2019 22:30:47)

x86_64 Arch Linux


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Antonio Giovanni Colombo

unread,
Nov 27, 2019, 2:42:17 AM11/27/19
to vim...@googlegroups.com, reply+ACY5DGA7OOMO66GH77...@reply.github.com
You should add the "-p" option to your command (as documented in the xxd man page):

$ echo -en '41414141\n\n' | xxd -r -p
AAAA$

Antonio


On Wed, Nov 27, 2019 at 6:25 AM aslvim <vim-dev...@256bit.org> wrote:

xxd -r hits an infinite loop for some inputs:

for example, echo -en '41414141\n\n' | xxd -r will run forever, spinning.

Environment:

xxd V1.10 27oct98 by Juergen Weigert
VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 7 2019 22:30:47)

x86_64 Arch Linux

--
   /||\    | Antonio Colombo
  / || \   |  azc...@gmail.com  
 /  ()  \  | ant...@geekcorp.com  
(___||___) |   az...@yahoo.com

vim-dev ML

unread,
Nov 27, 2019, 2:42:18 AM11/27/19
to vim/vim, vim-dev ML, Your activity
You should add the "-p" option to your command (as documented in the xxd
man page):

$ echo -en '41414141\n\n' | xxd -r -p
AAAA$

Antonio


On Wed, Nov 27, 2019 at 6:25 AM aslvim <vim-dev...@256bit.org> wrote:

> xxd -r hits an infinite loop for some inputs:
>
> for example, echo -en '41414141\n\n' | xxd -r will run forever, spinning.
>
> *Environment:*

>
> xxd V1.10 27oct98 by Juergen Weigert
> VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 7 2019 22:30:47)
>
> x86_64 Arch Linux
>
--
/||\ | Antonio Colombo
/ || \ | azc...@gmail.com
/ () \ | ant...@geekcorp.com
(___||___) | az...@yahoo.com

DungSaga

unread,
Oct 18, 2021, 7:52:12 AM10/18/21
to vim/vim, vim-dev ML, Comment

your input (41414141\n\n) means "go to offset 0x41414141". In this case, xxd is using standard input and output, and xxd cannot go directly to that offset. So, xxd writes zero bytes until it reach that offset.
This process will take a while, but it's not forever.
You can see this process in real time with a command like this: echo -en '41414141\n\n' | xxd -r | xxd -g1.

If you want to write 41414141 as 4 bytes, you should use xxd -r -p.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Christian Brabandt

unread,
Oct 18, 2021, 10:33:43 AM10/18/21
to vim/vim, vim-dev ML, Comment

I suppose this can be closed then.

Christian Brabandt

unread,
Oct 18, 2021, 10:33:45 AM10/18/21
to vim/vim, vim-dev ML, Comment

Closed #5272.

Reply all
Reply to author
Forward
0 new messages