Author: jilles
Date: Sun Aug 21 22:09:30 2011
New Revision: 225068
URL: http://svn.freebsd.org/changeset/base/225068

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/7/usr.bin/tail/forward.c
Directory Properties:
  stable/7/usr.bin/tail/   (props changed)

Modified: stable/7/usr.bin/tail/forward.c
==============================================================================
--- stable/7/usr.bin/tail/forward.c     Sun Aug 21 20:59:51 2011        
(r225067)
+++ stable/7/usr.bin/tail/forward.c     Sun Aug 21 22:09:30 2011        
(r225068)
@@ -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;
                                }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to