From 686084897c15348f42bde8e4d3448edfc78ece79 Mon Sep 17 00:00:00 2001 From: "Andrew G. Morgan" Date: Sat, 14 Aug 2021 10:28:14 -0700 Subject: [PATCH] Complete cap_launch fix. Samanta Navarro included this in their suggested fix, but I missed including it in the previous commit. Fixed now. Signed-off-by: Andrew G. Morgan --- libcap/cap_proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libcap/cap_proc.c b/libcap/cap_proc.c index 8116734..e12c8e6 100644 --- a/libcap/cap_proc.c +++ b/libcap/cap_proc.c @@ -878,6 +878,7 @@ static int _cap_chroot(struct syscaller_s *sc, const char *root) __attribute__ ((noreturn)) static void _cap_launch(int fd, cap_launch_t attr, void *detail) { struct syscaller_s *sc = &singlethread; + int my_errno; if (attr->custom_setup_fn && attr->custom_setup_fn(detail)) { goto defer; @@ -919,8 +920,9 @@ defer: * getting here means an error has occurred and errno is * communicated to the parent */ + my_errno = errno; for (;;) { - int n = write(fd, &errno, sizeof(errno)); + int n = write(fd, &my_errno, sizeof(my_errno)); if (n < 0 && errno == EAGAIN) { continue; }