summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-11-23 17:10:20 +0000
committerPádraig Brady <P@draigBrady.com>2016-11-24 00:24:21 +0000
commit68c5eeccd0365a6953d292550ffa5c537fa00f90 (patch)
tree7bbe212d8531f85d20937202fa41640fb84c5a3d
parent477a1e8ed493132e3741c5830c4bd30e19820951 (diff)
downloadcoreutils-68c5eeccd0365a6953d292550ffa5c537fa00f90.tar.xz
tail: fix checking of remoteness when not using inotify
In recent commit v8.25-93-g7fc7206 we used the f->remote flag which wasn't set in all cases. This was detected with ASAN giving this error when reading f->remote; runtime error: load of value 190, which is not a valid value for type '_Bool' * src/tail.c (fremote): Query the system even without inotify. (recheck): Always set f->fremote for valid files.
-rw-r--r--src/tail.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/tail.c b/src/tail.c
index 193e4fd7d..5c75be08d 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -878,9 +878,7 @@ start_lines (const char *pretty_filename, int fd, uintmax_t n_lines,
}
}
-#if HAVE_INOTIFY
-/* Without inotify support, always return false. Otherwise, return false
- when FD is open on a file known to reside on a local file system.
+/* Return false when FD is open on a file residing on a local file system.
If fstatfs fails, give a diagnostic and return true.
If fstatfs cannot be called, return true. */
static bool
@@ -888,7 +886,7 @@ fremote (int fd, const char *name)
{
bool remote = true; /* be conservative (poll by default). */
-# if HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE && defined __linux__
+#if HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE && defined __linux__
struct statfs buf;
int err = fstatfs (fd, &buf);
if (err != 0)
@@ -917,15 +915,10 @@ fremote (int fd, const char *name)
assert (!"unexpected return value from is_local_fs_type");
}
}
-# endif
+#endif
return remote;
}
-#else
-/* Without inotify support, whether a file is remote is irrelevant.
- Always return "false" in that case. */
-# define fremote(fd, name) false
-#endif
/* open/fstat F->name and handle changes. */
static void
@@ -995,7 +988,7 @@ recheck (struct File_spec *f, bool blocking)
quoteaf (pretty_name (f)),
f->ignore ? _("; giving up on this name") : "");
}
- else if (!disable_inotify && fremote (fd, pretty_name (f)))
+ else if ((f->remote = fremote (fd, pretty_name (f))) && ! disable_inotify)
{
ok = false;
f->errnum = -1;