posix_spawnattr_setflags(3): validate argument

Reviewed by:	emaste, kevans
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44195
This commit is contained in:
Konstantin Belousov 2024-03-03 15:19:37 +02:00
parent 2f5a315b30
commit 80ac36c3a2
2 changed files with 9 additions and 2 deletions

View File

@ -629,6 +629,10 @@ posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict sa,
int
posix_spawnattr_setflags(posix_spawnattr_t *sa, short flags)
{
if ((flags & ~(POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP |
POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER |
POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK)) != 0)
return (EINVAL);
(*sa)->sa_flags = flags;
return (0);
}

View File

@ -83,9 +83,12 @@ The default value of this attribute is as if no flags were set.
.Sh RETURN VALUES
The
.Fn posix_spawnattr_getflags
and
function returns zero.
The
.Fn posix_spawnattr_setflags
functions return zero.
function returns zero on success, and
.Er EINVAL
on failure due to invalid flag specified.
.Sh SEE ALSO
.Xr posix_spawn 3 ,
.Xr posix_spawnattr_destroy 3 ,