aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/networkmanager/networkmanager/0006-check-for-strndupa-before-using-it.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-networking/recipes-connectivity/networkmanager/networkmanager/0006-check-for-strndupa-before-using-it.patch')
-rw-r--r--meta-networking/recipes-connectivity/networkmanager/networkmanager/0006-check-for-strndupa-before-using-it.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/meta-networking/recipes-connectivity/networkmanager/networkmanager/0006-check-for-strndupa-before-using-it.patch b/meta-networking/recipes-connectivity/networkmanager/networkmanager/0006-check-for-strndupa-before-using-it.patch
new file mode 100644
index 0000000000..6adb84baa8
--- /dev/null
+++ b/meta-networking/recipes-connectivity/networkmanager/networkmanager/0006-check-for-strndupa-before-using-it.patch
@@ -0,0 +1,67 @@
+From f24d958fc85f9a43ac13abc85f74c4ae233dc8a4 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 31 Mar 2017 18:37:19 -0700
+Subject: [PATCH 6/7] check for strndupa before using it
+
+musl does not have strndupa
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ config.h.in | 4 ++++
+ configure.ac | 1 +
+ src/systemd/src/basic/alloc-util.h | 12 ++++++++++++
+ 3 files changed, 17 insertions(+)
+
+diff --git a/config.h.in b/config.h.in
+index edec211..0799030 100644
+--- a/config.h.in
++++ b/config.h.in
+@@ -34,6 +34,10 @@
+ */
+ #undef HAVE_DCGETTEXT
+
++/* Define to 1 if you have the declaration of `strndupa', and to 0 if you
++ don't. */
++#undef HAVE_DECL_STRNDUPA
++
+ /* Define to 1 if you have the declaration of `explicit_bzero', and to 0 if
+ you don't. */
+ #undef HAVE_DECL_EXPLICIT_BZERO
+diff --git a/configure.ac b/configure.ac
+index 8a066ad..51e5eb6 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -56,6 +56,7 @@ AC_SUBST(NM_VERSION)
+
+ GIT_SHA_RECORD(NM_GIT_SHA)
+
++AC_CHECK_DECLS([strndupa], [], [], [[#include <string.h>]])
+ dnl
+ dnl Checks for typedefs, structures, and compiler characteristics.
+ dnl
+diff --git a/src/systemd/src/basic/alloc-util.h b/src/systemd/src/basic/alloc-util.h
+index 0a89691..1e95260 100644
+--- a/src/systemd/src/basic/alloc-util.h
++++ b/src/systemd/src/basic/alloc-util.h
+@@ -25,6 +25,18 @@
+ #include <string.h>
+
+ #include "macro.h"
++#include "config.h"
++
++#if !HAVE_DECL_STRNDUPA
++#define strndupa(s, n) \
++ ({ \
++ const char *__old = (s); \
++ size_t __len = strnlen(__old, (n)); \
++ char *__new = (char *)alloca(__len + 1); \
++ __new[__len] = '\0'; \
++ (char *)memcpy(__new, __old, __len); \
++ })
++#endif
+
+ #define new(t, n) ((t*) malloc_multiply(sizeof(t), (n)))
+
+--
+2.14.1
+