summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-08-14 09:46:32 +0200
committerJim Meyering <jim@meyering.net>2007-08-14 09:47:05 +0200
commit1490f2dbf33ca75f060890013fb0d8caf28225aa (patch)
treedd888c957f308def22830487dfaf6a66060c517d /src
parented31c612c12e603ce86073952018bf7f00f9cd59 (diff)
downloadcoreutils-1490f2dbf33ca75f060890013fb0d8caf28225aa.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/od.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/od.c b/src/od.c
index 1e77f9208..0abce599a 100644
--- 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
{