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