NetBSD Problem Report #54939

From www@netbsd.org  Wed Feb  5 02:25:49 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 877BD1A9213
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  5 Feb 2020 02:25:49 +0000 (UTC)
Message-Id: <20200205022548.9F8111A924D@mollari.NetBSD.org>
Date: Wed,  5 Feb 2020 02:25:48 +0000 (UTC)
From: kevans@FreeBSD.org
Reply-To: kevans@FreeBSD.org
To: gnats-bugs@NetBSD.org
Subject: Small resource leak in O_SEARCH tests
X-Send-Pr-Version: www-1.0

>Number:         54939
>Category:       misc
>Synopsis:       Small resource leak in O_SEARCH tests
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 05 02:30:00 +0000 2020
>Closed-Date:    Wed Feb 05 08:53:22 +0000 2020
>Last-Modified:  Wed Feb 05 08:55:01 +0000 2020
>Originator:     Kyle Evans
>Release:        
>Organization:
>Environment:
>Description:
We've hooked up the O_SEARCH tests in FreeBSD now after implementing the POSIX-specified O_SEARCH semantics -- it points out this trivial resource leak if the function succeeds. Patch included below to close(dfd) before it goes out of scope.
>How-To-Repeat:

>Fix:
cvs diff: Diffing tests/lib/libc/c063
Index: tests/lib/libc/c063/t_o_search.c
===================================================================
RCS file: /cvsroot/src/tests/lib/libc/c063/t_o_search.c,v
retrieving revision 1.6
diff -u -r1.6 t_o_search.c
--- tests/lib/libc/c063/t_o_search.c	28 Jan 2020 07:12:08 -0000	1.6
+++ tests/lib/libc/c063/t_o_search.c	5 Feb 2020 02:22:32 -0000
@@ -260,6 +260,7 @@
 	ATF_REQUIRE((dfd = open(FILE, O_CREAT|O_RDWR|O_SEARCH, 0644)) != -1);
 	ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) == -1);
 	ATF_REQUIRE(errno == ENOTDIR);
+	ATF_REQUIRE(close(dfd) == 0);
 }

 ATF_TP_ADD_TCS(tp)

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Wed, 05 Feb 2020 08:53:22 +0000
State-Changed-Why:
Patch applied, thanks!


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54939 CVS commit: src/tests/lib/libc/c063
Date: Wed, 5 Feb 2020 08:52:46 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Feb  5 08:52:46 UTC 2020

 Modified Files:
 	src/tests/lib/libc/c063: t_o_search.c

 Log Message:
 PR misc/54939: fix file descriptor leak, patch from Kyle Evans.


 To generate a diff of this commit:
 cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/c063/t_o_search.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.