Skip to content

Commit 4b9fa95

Browse files
dungsagachrisbra
authored andcommitted
patch 9.1.0857: xxd: --- is incorrectly recognized as end-of-options
Problem: xxd: --- is incorrectly recognized as end-of-options Solution: improve xxds end-of-option parser (DungSaga) closes: #9285 Signed-off-by: DungSaga <dungsaga@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent a1b654f commit 4b9fa95

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/testdir/test_xxd.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,21 @@ endfunc
356356

357357
" Various ways with wrong arguments that trigger the usage output.
358358
func Test_xxd_usage()
359-
for arg in ['-h', '-c', '-g', '-o', '-s', '-l', '-X', '-R', 'one two three']
359+
for arg in ['-h', '-c', '-g', '-o', '-s', '-l', '-X', '-R', 'one two three', '----', '---']
360360
new
361361
exe 'r! ' . s:xxd_cmd . ' ' . arg
362362
call assert_match("Usage:", join(getline(1, 3)))
363363
bwipe!
364364
endfor
365365
endfunc
366366

367+
func Test_xxd_end_of_options()
368+
new
369+
exe 'r! ' . s:xxd_cmd . ' -- random-file-' . rand()
370+
call assert_match('random-file-.*: No such file or directory', join(getline(1, 3)))
371+
bwipe!
372+
endfunc
373+
367374
func Test_xxd_ignore_garbage()
368375
new
369376
exe 'r! printf "\n\r xxxx 0: 42 42" | ' . s:xxd_cmd . ' -r'

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
857,
707709
/**/
708710
856,
709711
/**/

src/xxd/xxd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
* 10.05.2024 fix another buffer-overflow when writing colored output to buffer, #14738
6666
* 10.09.2024 Support -b and -i together, #15661
6767
* 19.10.2024 -e did add an extra space #15899
68+
* 11.11.2024 improve end-of-options argument parser #9285
6869
*
6970
* (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com)
7071
*
@@ -145,7 +146,7 @@ extern void perror __P((char *));
145146
# endif
146147
#endif
147148

148-
char version[] = "xxd 2024-10-19 by Juergen Weigert et al.";
149+
char version[] = "xxd 2024-11-11 by Juergen Weigert et al.";
149150
#ifdef WIN32
150151
char osver[] = " (Win32)";
151152
#else
@@ -843,7 +844,7 @@ main(int argc, char *argv[])
843844
else
844845
exit_with_usage();
845846
}
846-
else if (!strcmp(pp, "--")) /* end of options */
847+
else if (!strcmp(argv[1], "--")) /* end of options */
847848
{
848849
argv++;
849850
argc--;

0 commit comments

Comments
 (0)