summaryrefslogtreecommitdiff
path: root/dev-libs/elfutils/files/musl/elfutils-0.185-strndupa.patch
blob: 030bc779c614c8ff8687f4de7dfb47ccde7fc414 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Should be fixed in next release (0.186?).

https://sourceware.org/git/?p=elfutils.git;a=commit;h=e7e4c92650892cf67210be5ea89ffba967427cbf
https://git.alpinelinux.org/aports/plain/main/elfutils/musl-strndupa.patch
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -56,6 +56,15 @@
 # define _(str) gettext (str)
 #endif
 
+#ifndef strndupa
+#define strndupa(s, n) \
+       (__extension__ ({const char *__in = (s);                    \
+                        size_t __len = strnlen (__in, (n)) + 1;    \
+                        char *__out = (char *) alloca (__len);     \
+                        __out[__len-1] = '\0';                     \
+                        (char *) memcpy (__out, __in, __len-1);}))
+#endif
+
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;