Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Aug 2011 13:37:38 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r224865 - head/usr.bin/tail
Message-ID:  <201108141337.p7EDbct2066244@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Aug 14 13:37:38 2011
New Revision: 224865
URL: http://svn.freebsd.org/changeset/base/224865

Log:
  tail: Fix crash if -F'ed file's filesystem disappears.
  
  If tail notices that a file it is following no longer exists (because stat()
  fails), it will output any final lines and then close the file. If the read
  operation also causes an error, such as when the filesystem is forcefully
  unmounted, it closes the file as well, leading to fclose(NULL) and a
  segmentation fault.
  
  PR:		bin/159750
  Submitted by:	swills
  Approved by:	re (kib)
  MFC after:	1 week

Modified:
  head/usr.bin/tail/forward.c

Modified: head/usr.bin/tail/forward.c
==============================================================================
--- head/usr.bin/tail/forward.c	Sun Aug 14 12:41:44 2011	(r224864)
+++ head/usr.bin/tail/forward.c	Sun Aug 14 13:37:38 2011	(r224865)
@@ -361,8 +361,10 @@ follow(file_info_t *files, enum STYLE st
 					if (errno != ENOENT)
 						ierr(file->file_name);
 					show(file);
-					fclose(file->fp);
-					file->fp = NULL;
+					if (file->fp != NULL) {
+						fclose(file->fp);
+						file->fp = NULL;
+					}
 					ev_change++;
 					continue;
 				}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108141337.p7EDbct2066244>