Date: Sat, 13 Aug 2011 22:47:18 GMT From: Steve Wills <swills@FreeBSD.org> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/159750: [PATCH] /usr/bin/tail can call fclose(NULL) causing core dump Message-ID: <201108132247.p7DMlItV082821@red.freebsd.org> Resent-Message-ID: <201108132250.p7DMo7w3025768@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 159750 >Category: bin >Synopsis: [PATCH] /usr/bin/tail can call fclose(NULL) causing core dump >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Aug 13 22:50:07 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Steve Wills >Release: >Organization: >Environment: >Description: I've been getting core dumps from tail when the FS it's on disappears. It can call fclose with a NULL argument, which causes the crash. >How-To-Repeat: run tail -F /path/to/file/on/md, then destroy the md(4) >Fix: See attached. Patch attached with submission follows: --- usr.bin/tail/forward.c.orig 2011-08-13 18:04:19.054770069 -0400 +++ usr.bin/tail/forward.c 2011-08-13 18:04:23.822771648 -0400 @@ -361,7 +361,9 @@ if (errno != ENOENT) ierr(file->file_name); show(file); - fclose(file->fp); + if (file->fp != NULL) { + fclose(file->fp); + } file->fp = NULL; ev_change++; continue; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108132247.p7DMlItV082821>