0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 9.1.1616: xxd: possible buffer overflow with bitwise output

Problem:  xxd: possible buffer overflow with bitwise output
          (after v9.1.1459, Xudong Cao)
Solution: Update LLEN_NO_COLOR macro definition for the max line output
          (using bitwise output -b)

fixes: #17944
closes: #17947

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-08-10 00:06:51 +02:00
parent 887b4981e7
commit eeef7c7743
4 changed files with 29 additions and 7 deletions

View File

@@ -680,4 +680,25 @@ func Test_xxd_color2()
call delete('XXDfile_colors')
unlet! $PS1
endfunc
" this caused a buffer overflow
func Test_xxd_overflow()
CheckUnix
CheckExecutable /bin/true
new
" we are only checking, that there are addresses in the first 5 lines
let expected = [
\ '00000000: ',
\ '00000080: ',
\ '00000100: ',
\ '00000180: ',
\ '00000200: ']
exe "0r! " s:xxd_cmd "-b -E -c 128 -g 256 /bin/true 2>&1"
" there should not be an ASAN error message
call getline(1, '$')->join('\n')->assert_notmatch('runtime error')
6,$d
%s/^\x\+: \zs.*//g
call assert_equal(expected, getline(1, 5))
bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab