NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

misc/54939: Small resource leak in O_SEARCH tests



>Number:         54939
>Category:       misc
>Synopsis:       Small resource leak in O_SEARCH tests
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 05 02:30:00 +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)



Home | Main Index | Thread Index | Old Index