From owner-svn-src-stable@FreeBSD.ORG Sun Aug 21 20:59:51 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 939EE106564A; Sun, 21 Aug 2011 20:59:51 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81EA58FC0C; Sun, 21 Aug 2011 20:59:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7LKxpeG019491; Sun, 21 Aug 2011 20:59:51 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LKxpmt019489; Sun, 21 Aug 2011 20:59:51 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201108212059.p7LKxpmt019489@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 21 Aug 2011 20:59:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225067 - stable/8/usr.bin/tail X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Aug 2011 20:59:51 -0000 Author: jilles Date: Sun Aug 21 20:59:51 2011 New Revision: 225067 URL: http://svn.freebsd.org/changeset/base/225067 Log: MFC r224865: 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 Modified: stable/8/usr.bin/tail/forward.c Directory Properties: stable/8/usr.bin/tail/ (props changed) Modified: stable/8/usr.bin/tail/forward.c ============================================================================== --- stable/8/usr.bin/tail/forward.c Sun Aug 21 18:50:30 2011 (r225066) +++ stable/8/usr.bin/tail/forward.c Sun Aug 21 20:59:51 2011 (r225067) @@ -365,8 +365,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; }