]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
od: add test cases for recent fix
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 30 Jun 2025 05:31:01 +0000 (22:31 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 30 Jun 2025 05:32:05 +0000 (22:32 -0700)
* tests/od/od.pl: New tests for the offset issues

NEWS
tests/od/od.pl

diff --git a/NEWS b/NEWS
index a85840dda34bea8438e02d348c3d81b46f4c7d3a..87ba2659cf4f6060d163d44c88cc836a4848a2fb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   od '+N.' (where N is a decimal number) works again as per POSIX.
   [bug introduced in textutils-2.0]
 
+  'od /dev/null ++0' no longer mistakenly treats the ++0 as an offset.
+  [This bug was present in "the beginning".]
+
   sort with key character offsets of SIZE_MAX, could induce
   a read of 1 byte before an allocated heap buffer. For example:
   'sort +0.18446744073709551615R input' on 64 bit systems.
index 9688607c6e79889f2b474269288ecb5a6c882731..e4e328ad6802f83bc5885dacf9e9a8065e0a7887 100755 (executable)
@@ -64,6 +64,24 @@ my @Tests =
      ['trad-dot1', '+1.', {IN_PIPE=>'a'}, {OUT=>"0000001\n"}],
      ['trad-dot512', '+1.b', {IN_PIPE => 'a' x 512}, {OUT=>"0001000\n"}],
 
+     # Invalid traditional offsets should be treated as file names.
+     ['invalid-off-1', '++0', {IN_PIPE=>""}, {EXIT=>1},
+      {ERR=>"$prog: ++0: No such file or directory\n"}],
+     ['invalid-off-2', '+-0', {IN_PIPE=>""}, {EXIT=>1},
+      {ERR=>"$prog: +-0: No such file or directory\n"}],
+     ['invalid-off-3', '"+ 0"', {IN_PIPE=>""}, {EXIT=>1},
+      {ERR=>"$prog: '+ 0': No such file or directory\n"}],
+     ['invalid-off-4', '-- -0', {IN_PIPE=>""}, {EXIT=>1},
+      {ERR=>"$prog: -0: No such file or directory\n"}],
+
+     # Overflowing traditional offsets should be diagnosed.
+     ['overflow-off-1', '-', '7' x 255, {IN_PIPE=>""}, {EXIT=>1},
+      {ERR=>"od: ".('7' x 255).": Numerical result out of range\n"}],
+     ['overflow-off-2', '-', ('9' x 254).'.', {IN_PIPE=>""}, {EXIT=>1},
+      {ERR=>"od: ".('9' x 254).".: Numerical result out of range\n"}],
+     ['overflow-off-3', '-', '0x'.('f' x 253), {IN_PIPE=>""}, {EXIT=>1},
+      {ERR=>"od: 0x".('f' x 253).": Numerical result out of range\n"}],
+
      # Ensure that a large width does not cause trouble.
      # From coreutils-7.0 through coreutils-8.21, these would print
      # approximately 128KiB of padding.