Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2016 06:55:53 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300660 - head/lib/libc/gen
Message-ID:  <201605250655.u4P6trZO015446@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Wed May 25 06:55:53 2016
New Revision: 300660
URL: https://svnweb.freebsd.org/changeset/base/300660

Log:
  Fix 1016718 Resource leak.
  
  Don't leak a file descriptor if fchdir() fails.
  
  Reported by:	Coverity
  CID:		1016718
  MFC after:	1 week

Modified:
  head/lib/libc/gen/fts-compat.c

Modified: head/lib/libc/gen/fts-compat.c
==============================================================================
--- head/lib/libc/gen/fts-compat.c	Wed May 25 06:47:28 2016	(r300659)
+++ head/lib/libc/gen/fts-compat.c	Wed May 25 06:55:53 2016	(r300660)
@@ -573,8 +573,10 @@ __fts_children_44bsd(FTS *sp, int instr)
 	if ((fd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0)
 		return (NULL);
 	sp->fts_child = fts_build(sp, instr);
-	if (fchdir(fd))
+	if (fchdir(fd)) {
+		(void)_close(fd);
 		return (NULL);
+	}
 	(void)_close(fd);
 	return (sp->fts_child);
 }



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