.gitignore: updated
[dragora.git] / patches / libcap / Avoid-sys-capability.h-on-build-architecture.patch
blob59d31f2f23315f52d4d46f0026fddf50cd2a5c87
1 From: Helmut Grohne <helmut@subdivi.de>
2 Date: Wed, 30 Dec 2015 22:35:40 +0100
3 Subject: Avoid sys/capability.h on build architecture
5 libcap/_makenames.c generates a build-time helper, and as such is compiled for
6 the build architecture. The use of sys/capability.h which depends on an arch-
7 specific Linux header eventually leads to a FTCBFS.
9 However, the only reason to use the header is to estimate the size of an array
10 "pointers" in _makenames.c. Rather than using this guess, the array can simply
11 be allocated dynamically.
13 Bug-Debian: https://bugs.debian.org/809467
14 Origin: other, https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=no_sys_capability_h.patch;att=1;bug=809467
15 Forwarded: no
16 Last-Update: 2015-12-30
17 ---
18 libcap/_makenames.c | 16 ++++++++++++----
19 1 file changed, 12 insertions(+), 4 deletions(-)
21 diff --git a/libcap/_makenames.c b/libcap/_makenames.c
22 index 8cc819b..03dd684 100644
23 --- a/libcap/_makenames.c
24 +++ b/libcap/_makenames.c
25 @@ -7,7 +7,6 @@
27 #include <stdio.h>
28 #include <stdlib.h>
29 -#include <sys/capability.h>
32 * #include 'sed' generated array
33 @@ -21,17 +20,25 @@ struct {
34 {NULL, -1}
37 -/* this should be more than big enough (factor of three at least) */
38 -const char *pointers[8*sizeof(struct __user_cap_data_struct)];
40 int main(void)
42 int i, maxcaps=0;
43 + const char **pointers = NULL, **pointers_tmp;
44 + int pointers_avail = 0;
46 for ( i=0; list[i].index >= 0 && list[i].name; ++i ) {
47 if (maxcaps <= list[i].index) {
48 maxcaps = list[i].index + 1;
50 + if (list[i].index >= pointers_avail) {
51 + pointers_avail = 2 * list[i].index + 1;
52 + pointers_tmp = realloc(pointers, pointers_avail * sizeof(char *));
53 + if (!pointers_tmp) {
54 + fputs("out of memory", stderr);
55 + exit(1);
56 + }
57 + pointers = pointers_tmp;
58 + }
59 pointers[list[i].index] = list[i].name;
62 @@ -57,5 +64,6 @@ int main(void)
63 "\n"
64 "/* END OF FILE */\n");
66 + free(pointers);
67 exit(0);