]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
od: fix a bug that arises when skipping exact length of file
authorJim Meyering <jim@meyering.net>
Tue, 14 Aug 2007 07:46:32 +0000 (09:46 +0200)
committerJim Meyering <jim@meyering.net>
Tue, 14 Aug 2007 07:47:05 +0000 (09:47 +0200)
* NEWS: Document the bug fix.
* src/od.c (skip): Call fseek even when n_skip is exactly the
same as the length of the current file.  Otherwise, the next
iteration would use unadjusted input stream pointer, thus ignoring
the desired "skip".  Report and patch by Paul GHALEB.

ChangeLog
NEWS
THANKS
src/od.c

index 1cd7390b4246f95cbdf3bc07150e5c09fc9f5e77..df1718e74f2c351456edded3627b17153ca7c16d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-08-14  Jim Meyering  <jim@meyering.net>
+
+       od: fix a bug that arises when skipping exact length of file
+       * NEWS: Document the bug fix.
+       * src/od.c (skip): Call fseek even when n_skip is exactly the
+       same as the length of the current file.  Otherwise, the next
+       iteration would use unadjusted input stream pointer, thus ignoring
+       the desired "skip".  Report and patch by Paul GHALEB.
+
 2007-08-10  Paul Eggert  <eggert@cs.ucla.edu>
 
        Accommodate more xstrtol changes.
diff --git a/NEWS b/NEWS
index 83d06b7537a7cf8697188b5fea58c56f7023cb0c..13d3402f10bb638ec900a83c0519425daf184362 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -98,6 +98,11 @@ GNU coreutils NEWS                                    -*- outline -*-
   ln=target attribute) would mistakenly output the string "target"
   before the name of each symlink.  [introduced in coreutils-6.0]
 
+  "od -j L FILE" had a bug: when the number of bytes to skip, L, is exactly
+  the same as the length of FILE, od would skip *no* bytes.  When the number
+  of bytes to skip is exactly the sum of the lengths of the first N files,
+  od would skip only the first N-1 files. [introduced in textutils-2.0.9]
+
   seq no longer mishandles obvious cases like "seq 0 0.000001 0.000003",
   so workarounds like "seq 0 0.000001 0.0000031" are no longer needed.
 
diff --git a/THANKS b/THANKS
index ae5269f31bcd57962aef102f6cbd568097ac6411..cdddec497f6ded46bbc02b8f85856375e65fbd61 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -397,6 +397,7 @@ Oskar Liljeblad                     osk@hem.passagen.se
 Pádraig Brady                       P@draigBrady.com
 Patrick Mauritz                     oxygene@studentenbude.ath.cx
 Paul Eggert                         eggert@twinsun.com
+Paul Ghaleb                         paul.ghaleb@st.com
 Paul Jarc                           prj@po.cwru.edu
 Paul Nevai                          nevai@ops.mps.ohio-state.edu
 Paul Sauer                          paul@alexa.com
index 1e77f9208436405d14a765ab3773abae4e18e81b..0abce599a5a82e3ce0a03c88ff91207cb59d5a53 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -1034,13 +1034,12 @@ skip (uintmax_t n_skip)
        {
          /* The st_size field is valid only for regular files
             (and for symbolic links, which cannot occur here).
-            If the number of bytes left to skip is at least
-            as large as the size of the current file, we can
-            decrement n_skip and go on to the next file.  */
-
+            If the number of bytes left to skip is larger than
+            the size of the current file, we can decrement
+            n_skip and go on to the next file.  */
          if (S_ISREG (file_stats.st_mode) && 0 <= file_stats.st_size)
            {
-             if ((uintmax_t) file_stats.st_size <= n_skip)
+             if ((uintmax_t) file_stats.st_size < n_skip)
                n_skip -= file_stats.st_size;
              else
                {