Package: libcap-ng / 0.7.7-3

02_fix_armel_segfault_memset.patch Patch series | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Index: libcap-ng/src/cap-ng.c
===================================================================
--- libcap-ng.orig/src/cap-ng.c	2011-06-11 16:27:05.000000000 +0200
+++ libcap-ng/src/cap-ng.c	2012-06-16 22:28:05.181687824 +0200
@@ -136,6 +136,11 @@
 	__u32 bounds[2];
 };
 
+
+static struct __user_cap_header_struct hdrzz = {0, 0};
+static cap_data_t datazz = { {0, 0, 0} };
+static __u32 boundzz = {0};
+
 // Global variables with per thread uniqueness
 static __thread struct cap_ng m =	{ 1,
 					{0, 0},
@@ -149,7 +154,7 @@
 	if (m.state != CAPNG_NEW)
 		return;
 
-	memset(&m.hdr, 0, sizeof(m.hdr));
+	m.hdr = hdrzz;
 	(void)capget(&m.hdr, NULL); // Returns -EINVAL
 	if (m.hdr.version == _LINUX_CAPABILITY_VERSION_3 ||
 		m.hdr.version == _LINUX_CAPABILITY_VERSION_2) {
@@ -161,7 +166,7 @@
 		return;
 	}
 
-	memset(&m.data, 0, sizeof(cap_data_t));
+	m.data = datazz;
 #ifdef HAVE_SYSCALL_H
 	m.hdr.pid = (unsigned)syscall(__NR_gettid);
 #else
@@ -178,10 +183,13 @@
 		return;
 
 	if (set & CAPNG_SELECT_CAPS)
-		memset(&m.data, 0, sizeof(cap_data_t));
+		m.data = datazz;
 #ifdef PR_CAPBSET_DROP
-	if (set & CAPNG_SELECT_BOUNDS)
-		memset(m.bounds, 0, sizeof(m.bounds));
+	if (set & CAPNG_SELECT_BOUNDS) {
+		unsigned i;
+		for (i=0; i<sizeof(m.bounds)/sizeof(__u32); i++)
+			m.bounds[i] = boundzz;
+	}
 #endif
 	m.state = CAPNG_INIT;
 }