Problem: xxd: cannot use -b and -i together
(Irgendwer)
Solution: implement the missing changes
(Andre Chang)
fixes: #15362closes: #15661
Signed-off-by: Andre Chang <andre@augmentcode.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: style issues with man pages
Solution: update man pages and test_xxd.vim, since it uses
the xxd man page (RestorerZ)
closes: #15489
Signed-off-by: RestorerZ <restorer@mail2k.ru>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: [security] xxd: buffer-overflow with specific flags
Solution: Correctly calculate the required buffer space
(Lennard Hofmann)
xxd writes each output line into a global buffer before printing.
The maximum size of that buffer was not calculated correctly.
This command was crashing in AddressSanitizer:
$ xxd -Ralways -g1 -c256 -d -o 9223372036854775808 /etc/passwd
This prints a line of 6680 bytes but the buffer only had room for 6549 bytes.
If the output from "-b" was colored, the line could be even longer.
closes: #14738
Co-authored-by: K.Takata <kentkt@csc.jp>
Signed-off-by: Lennard Hofmann <lennard.hofmann@web.de>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: xxd: cannot reverse a bit dump
Solution: implement reversing the bit dump using -b -r
closes: #13286
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: tristhaus <tristhaus@yahoo.de>
Problem: Some problems with xxd coloring
Solution: Fix the following problems:
* Support colored output on Windows.
SetConsoleMode() is required to enable ANSI color sequences.
* Support "NO_COLOR" environment variable.
If "NO_COLOR" is defined and not empty, colored output should be
disabled.
See https://no-color.org/
* "-R" should only accept "always", "never" or "auto" as the parameter.
* Adjust help and documentation. "-R" cannot omit the parameter. Remove
surrounding brackets.
Related #12131closes: #12997closes: #12991closes: #12986
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: K.Takata <kentkt@csc.jp>
Problem: xxd: no color support
Solution: Add color support using xxd -R
Add some basic color support for xxd
The hex-value and value are both colored with the same color depending
on the hex-value, e.g.:
0x00 = white
0xff = blue
printable = green
non-printable = red
tabs and linebreaks = yellow
Each character needs 11 more bytes to contain color. (Same color in a
row could contain only one overhead but the logic how xxd creates colums
must be then changed.) Size of colored output is increased by factor of
~6. Also grepping the output will break when colors is used.
Flag for color is "-R", because less uses "-R".
Color uses parameters auto,always,never same as less and grep (among
others).
E.g.
xxd -R always $FILE | less -R
Add some screen-tests (that currently on work on linux) to verify the
feature works as expected.
closes: #12131
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Aapo Rantalainen <aapo.rantalainen@gmail.com>