]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0394: xxd: offsets greater than LONG_MAX print as negative v9.2.0394
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Sun, 26 Apr 2026 08:22:23 +0000 (08:22 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 26 Apr 2026 08:22:23 +0000 (08:22 +0000)
Problem:  xxd: offsets greater than LONG_MAX print as negative
Solution: Use "%lu" to print unsigned long value
          (Yasuhiro Matsumoto)

closes: #20055

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_xxd.vim
src/version.c
src/xxd/xxd.c

index 472dfd4ee9da5bb75daec0642b9478a32d8c9d9a..430a07ccfbb595daf6f5f6a50119152eefba20d9 100644 (file)
@@ -476,7 +476,7 @@ func Test_xxd_buffer_overflow()
   endif
   new
   let input = repeat('A', 256)
-  call writefile(['-9223372036854775808: ' . repeat("\e[1;32m41\e[0m ", 256) . ' ' . "\e[1;32m" . repeat('A', 256) . "\e[0m"], 'Xxdexpected', 'D')
+  call writefile(['9223372036854775808: ' . repeat("\e[1;32m41\e[0m ", 256) . ' ' . "\e[1;32m" . repeat('A', 256) . "\e[0m"], 'Xxdexpected', 'D')
   exe 'r! printf ' . input . '| ' . s:xxd_cmd . ' -Ralways -g1 -c256 -d -o 9223372036854775808 > Xxdout'
   call assert_equalfile('Xxdexpected', 'Xxdout')
   call delete('Xxdout')
index d4b5c51000351628856c78b63cda38bb027e9880..0946dbadc15d7b1eb8a5d268d923b22da9580d05 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    394,
 /**/
     393,
 /**/
index 535f0add32113adff79f06fd034fed47815c6394..fb45f6c2846d91fc6ca4e7167e49fcc4cb12181b 100644 (file)
@@ -74,6 +74,7 @@
  * 26.11.2025  update indent in exit_with_usage()
  * 19.03.2026  Add -t option to end output with terminating null
  * 25.03.2026  Fix color output issues
+ * 26.04.2026  Use unsigned long for printing offsets
  *
  * (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com)
  *
@@ -154,7 +155,7 @@ extern void perror __P((char *));
 # endif
 #endif
 
-char version[] = "xxd 2026-03-25 by Juergen Weigert et al.";
+char version[] = "xxd 2026-04-26 by Juergen Weigert et al.";
 #ifdef WIN32
 char osver[] = " (Win32)";
 #else
@@ -1172,7 +1173,7 @@ main(int argc, char *argv[])
     {
       if (p == 0)
        {
-         addrlen = sprintf(l, decimal_offset ? "%08ld:" : "%08lx:",
+         addrlen = sprintf(l, decimal_offset ? "%08lu:" : "%08lx:",
                                  ((unsigned long)(n + seekoff + displayoff)));
          for (c = addrlen; c < LLEN_NO_COLOR; l[c++] = ' ')
            ;