fusefs: correct mmap()'s return value in the allow_other test

Also, properly cleanup the semaphore.

Reported by:	ngie
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-03-27 03:02:54 +00:00
parent e0bec057db
commit 477c462834

View File

@ -107,7 +107,7 @@ TEST_F(AllowOther, allowed)
int mflags = MAP_ANON | MAP_SHARED;
sem = (sem_t*)mmap(NULL, sizeof(*sem), mprot, mflags, -1, 0);
ASSERT_NE(NULL, sem) << strerror(errno);
ASSERT_NE(MAP_FAILED, sem) << strerror(errno);
ASSERT_EQ(0, sem_init(sem, 1, 0)) << strerror(errno);
if ((child = fork()) == 0) {
@ -126,6 +126,7 @@ TEST_F(AllowOther, allowed)
}
_exit(0);
sem_destroy(sem);
/* Deliberately leak fd */
} else if (child > 0) {
int child_status;
@ -149,6 +150,7 @@ TEST_F(AllowOther, allowed)
} else {
FAIL() << strerror(errno);
}
munmap(sem, sizeof(*sem));
}
TEST_F(NoAllowOther, disallowed)
@ -161,7 +163,7 @@ TEST_F(NoAllowOther, disallowed)
int mflags = MAP_ANON | MAP_SHARED;
sem = (sem_t*)mmap(NULL, sizeof(*sem), mprot, mflags, -1, 0);
ASSERT_NE(NULL, sem) << strerror(errno);
ASSERT_NE(MAP_FAILED, sem) << strerror(errno);
ASSERT_EQ(0, sem_init(sem, 1, 0)) << strerror(errno);
if ((child = fork()) == 0) {
@ -184,6 +186,7 @@ TEST_F(NoAllowOther, disallowed)
}
_exit(0);
sem_destroy(sem);
/* Deliberately leak fd */
} else if (child > 0) {
/*
@ -200,4 +203,5 @@ TEST_F(NoAllowOther, disallowed)
} else {
FAIL() << strerror(errno);
}
munmap(sem, sizeof(*sem));
}