aboutsummaryrefslogtreecommitdiffstats
path: root/main/libcap-ng/async-safe-apply.patch
blob: 1542863e74c4b8f9708f0e6604fb235dca6de130 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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