diff options
author | Jim Meyering <meyering@redhat.com> | 2012-05-07 09:32:00 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-05-08 18:32:58 +0200 |
commit | a6f94fcebc1645b401eedacbffb5e2ebdedf0f95 (patch) | |
tree | f53d31b2f1d8555e5d3fad86782e592aa71a0c33 /src | |
parent | 30071b2f5cb8135154cbc7bb0ec76c5926d2b983 (diff) | |
download | coreutils-a6f94fcebc1645b401eedacbffb5e2ebdedf0f95.tar.xz |
split: avoid apparent infloop when splitting /dev/zero w/-n on the Hurd
* src/split.c (main): Use stat.st_size only for regular files.
Samuel Thibault reported in http://bugs.gnu.org/11424 that the
/dev/zero-splitting tests would appear to infloop on GNU/Hurd,
because /dev/zero's st_size is LONG_MAX. It was only a problem
when using the --number (-n) option.
* NEWS (Bug fixes): Mention it.
This bug was introduced with the --number option, via
commit v8.7-25-gbe10739
Diffstat (limited to 'src')
-rw-r--r-- | src/split.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/split.c b/src/split.c index 99f639016..062aedea9 100644 --- a/src/split.c +++ b/src/split.c @@ -1339,7 +1339,9 @@ main (int argc, char **argv) error (EXIT_FAILURE, errno, "%s", infile); if (in_blk_size == 0) in_blk_size = io_blksize (stat_buf); - file_size = stat_buf.st_size; + + /* stat.st_size is valid only for regular files. For others, use 0. */ + file_size = S_ISREG (stat_buf.st_mode) ? stat_buf.st_size : 0; if (split_type == type_chunk_bytes || split_type == type_chunk_lines) { |