aboutsummaryrefslogtreecommitdiffstats
path: root/main/libcap-ng/async-safe-apply.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/libcap-ng/async-safe-apply.patch')
-rw-r--r--main/libcap-ng/async-safe-apply.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/main/libcap-ng/async-safe-apply.patch b/main/libcap-ng/async-safe-apply.patch
new file mode 100644
index 0000000000..1542863e74
--- /dev/null
+++ b/main/libcap-ng/async-safe-apply.patch
@@ -0,0 +1,29 @@
+Upstream: https://github.com/stevegrubb/libcap-ng/pull/16
+diff --git a/src/cap-ng.c b/src/cap-ng.c
+index 7aa1029..f0ad7e7 100644
+--- a/src/cap-ng.c
++++ b/src/cap-ng.c
+@@ -525,11 +525,12 @@ int capng_apply(capng_select_t set)
+
+ if (set & CAPNG_SELECT_BOUNDS) {
+ #ifdef PR_CAPBSET_DROP
+- void *s = capng_save_state();
++ struct cap_ng state;
++ memcpy(&state, &m, sizeof(state)); /* save state */
+ capng_get_caps_process();
+ if (capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP)) {
+ int i;
+- capng_restore_state(&s);
++ memcpy(&m, &state, sizeof(m)); /* restore state */
+ rc = 0;
+ for (i=0; i <= last_cap && rc == 0; i++)
+ if (capng_have_capability(CAPNG_BOUNDING_SET,
+@@ -538,7 +539,7 @@ int capng_apply(capng_select_t set)
+ if (rc == 0)
+ m.state = CAPNG_APPLIED;
+ } else
+- capng_restore_state(&s);
++ memcpy(&m, &state, sizeof(m)); /* restore state */
+ #else
+ rc = 0;
+ #endif