git: 80ac36c3a2a8 - main - posix_spawnattr_setflags(3): validate argument
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 04 Mar 2024 01:00:45 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=80ac36c3a2a87a19790eba487466bf70d55f566e commit 80ac36c3a2a87a19790eba487466bf70d55f566e Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-03-03 13:19:37 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-03-04 01:00:38 +0000 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 --- lib/libc/gen/posix_spawn.c | 4 ++++ lib/libc/gen/posix_spawnattr_getflags.3 | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index a067d1f68ea5..41e059cf437b 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -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); } diff --git a/lib/libc/gen/posix_spawnattr_getflags.3 b/lib/libc/gen/posix_spawnattr_getflags.3 index 9a468cbb8b0f..18cf6683e935 100644 --- a/lib/libc/gen/posix_spawnattr_getflags.3 +++ b/lib/libc/gen/posix_spawnattr_getflags.3 @@ -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 ,