]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: avoid rare error-path FD leak
authorJim Meyering <meyering@redhat.com>
Fri, 27 Jul 2012 21:42:05 +0000 (23:42 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 3 Aug 2012 12:54:01 +0000 (14:54 +0200)
* src/tail.c (tail_forever): Close FD to avoid leak after a
failed fstat.

src/tail.c

index 1935605efb6c2aa56ffd9f247ec9ec14098118de..290ada48396357fb7d247108ea643a81887dbf18 100644 (file)
@@ -1141,6 +1141,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval)
                   f[i].fd = -1;
                   f[i].errnum = errno;
                   error (0, errno, "%s", name);
+                  close (fd); /* ignore failure */
                   continue;
                 }