File tree Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -680,4 +680,25 @@ func Test_xxd_color2()
680
680
call delete (' XXDfile_colors' )
681
681
unlet ! $PS1
682
682
endfunc
683
+
684
+ " this caused a buffer overflow
685
+ func Test_xxd_overflow ()
686
+ CheckUnix
687
+ CheckExecutable /bin/ true
688
+ new
689
+ " we are only checking, that there are addresses in the first 5 lines
690
+ let expected = [
691
+ \ ' 00000000: ' ,
692
+ \ ' 00000080: ' ,
693
+ \ ' 00000100: ' ,
694
+ \ ' 00000180: ' ,
695
+ \ ' 00000200: ' ]
696
+ exe " 0r! " s: xxd_cmd " -b -E -c 128 -g 256 /bin/true 2>&1"
697
+ " there should not be an ASAN error message
698
+ call getline (1 , ' $' )- >join (' \n' )- >assert_notmatch (' runtime error' )
699
+ 6 ,$d
700
+ % s /^\x\+: \zs.*/ /g
701
+ call assert_equal (expected, getline (1 , 5 ))
702
+ bw !
703
+ endfunc
683
704
" vim: shiftwidth = 2 sts = 2 expandtab
Original file line number Diff line number Diff line change @@ -719,6 +719,8 @@ static char *(features[]) =
719
719
720
720
static int included_patches [] =
721
721
{ /* Add new patch number below this line */
722
+ /**/
723
+ 1616 ,
722
724
/**/
723
725
1615 ,
724
726
/**/
Original file line number Diff line number Diff line change 1
1
# The most simplistic Makefile
2
2
3
+ # SANITIZER_CFLAGS=-g -O0 -fsanitize-recover=all -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
4
+
3
5
xxd : xxd.c
4
- $(CC ) $(CFLAGS ) $(CPPFLAGS ) $(LDFLAGS ) -DUNIX -o xxd xxd.c $(LIBS )
6
+ $(CC ) $(SANITIZER_CFLAGS ) $( CFLAGS ) $(CPPFLAGS ) $(LDFLAGS ) -DUNIX -o xxd xxd.c $(LIBS )
5
7
6
8
clean :
7
9
rm -f xxd xxd.o
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ extern void perror __P((char *));
148
148
# endif
149
149
#endif
150
150
151
- char version [] = "xxd 2025-06-15 by Juergen Weigert et al." ;
151
+ char version [] = "xxd 2025-08-08 by Juergen Weigert et al." ;
152
152
#ifdef WIN32
153
153
char osver [] = " (Win32)" ;
154
154
#else
@@ -228,10 +228,9 @@ char osver[] = "";
228
228
#define LLEN_NO_COLOR \
229
229
(39 /* addr: ⌈log10(ULONG_MAX)⌉ if "-d" flag given. We assume ULONG_MAX = 2**128 */ \
230
230
+ 2 /* ": " */ \
231
- + 2 * COLS /* hex dump */ \
232
- + (COLS - 1 ) /* whitespace between groups if "-g1" option given and "-c" maxed out */ \
231
+ + 9 * COLS /* hex dump, worst case: bitwise output using -b */ \
233
232
+ 2 /* whitespace */ \
234
- + COLS /* ASCII dump */ \
233
+ + COLS /* ASCII dump */ \
235
234
+ 2 ) /* "\n\0" */
236
235
237
236
char hexxa [] = "0123456789abcdef0123456789ABCDEF" , * hexx = hexxa ;
@@ -1182,9 +1181,7 @@ main(int argc, char *argv[])
1182
1181
1183
1182
c += addrlen + 3 + p ;
1184
1183
if (color )
1185
- {
1186
1184
colors [c ] = cur_color ;
1187
- }
1188
1185
l [c ++ ] =
1189
1186
#if defined(__MVS__ ) && __CHARSET_LIB == 0
1190
1187
(e >= 64 )
You can’t perform that action at this time.
0 commit comments