Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Mar 2019 00:25:57 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r345623 - projects/fuse2/tests/sys/fs/fusefs
Message-ID:  <201903280025.x2S0Pv8W042498@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Thu Mar 28 00:25:57 2019
New Revision: 345623
URL: https://svnweb.freebsd.org/changeset/base/345623

Log:
  fusefs: fix a resource leak in the allow_other tests
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/fuse2/tests/sys/fs/fusefs/allow_other.cc

Modified: projects/fuse2/tests/sys/fs/fusefs/allow_other.cc
==============================================================================
--- projects/fuse2/tests/sys/fs/fusefs/allow_other.cc	Wed Mar 27 22:51:48 2019	(r345622)
+++ projects/fuse2/tests/sys/fs/fusefs/allow_other.cc	Thu Mar 28 00:25:57 2019	(r345623)
@@ -112,21 +112,25 @@ TEST_F(AllowOther, allowed)
 
 	if ((child = fork()) == 0) {
 		/* In child */
+		int err = 0;
+
 		ASSERT_EQ(0, sem_wait(sem)) << strerror(errno);
 
 		/* Drop privileges before accessing */
 		if (0 != setreuid(-1, m_uid)) {
 			perror("setreuid");
-			_exit(1);
+			err = 1;
+			goto out;
 		}
 		fd = open(FULLPATH, O_RDONLY);
 		if (fd < 0) {
 			perror("open");
-			_exit(1);
+			err = 1;
 		}
-		_exit(0);
 
+out:
 		sem_destroy(sem);
+		_exit(err);
 		/* Deliberately leak fd */
 	} else if (child > 0) {
 		int child_status;
@@ -168,25 +172,29 @@ TEST_F(NoAllowOther, disallowed)
 
 	if ((child = fork()) == 0) {
 		/* In child */
+		int err = 0;
+
 		ASSERT_EQ(0, sem_wait(sem)) << strerror(errno);
 
 		/* Drop privileges before accessing */
 		if (0 != setreuid(-1, m_uid)) {
 			perror("setreuid");
-			_exit(1);
+			err = 1;
+			goto out;
 		}
 		fd = open(FULLPATH, O_RDONLY);
 		if (fd >= 0) {
 			fprintf(stderr, "open should've failed\n");
-			_exit(1);
+			err = 1;
 		} else if (errno != EPERM) {
 			fprintf(stderr,
 				"Unexpected error: %s\n", strerror(errno));
-			_exit(1);
+			err = 1;
 		}
-		_exit(0);
 
+out:
 		sem_destroy(sem);
+		_exit(0);
 		/* Deliberately leak fd */
 	} else if (child > 0) {
 		/* 



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