diff options
Diffstat (limited to 'meta/recipes-support/libnl/libnl/0001-lib-add-utility-function-nl_strerror_l.patch')
-rw-r--r-- | meta/recipes-support/libnl/libnl/0001-lib-add-utility-function-nl_strerror_l.patch | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/meta/recipes-support/libnl/libnl/0001-lib-add-utility-function-nl_strerror_l.patch b/meta/recipes-support/libnl/libnl/0001-lib-add-utility-function-nl_strerror_l.patch new file mode 100644 index 0000000000..b734028c73 --- /dev/null +++ b/meta/recipes-support/libnl/libnl/0001-lib-add-utility-function-nl_strerror_l.patch | |||
@@ -0,0 +1,146 @@ | |||
1 | From 683f27fbb68ca2028a7b3468f17164d484df2759 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <adraszik@tycoint.com> | ||
3 | Date: Thu, 25 Aug 2016 13:14:59 +0100 | ||
4 | Subject: [PATCH 1/3] lib: add utility function nl_strerror_l() | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | libnl currently uses strerror_r() throughout, but this is | ||
10 | problematic because there is a non-standard GNU version | ||
11 | implemented in glibc, and the standard POSIX version, which | ||
12 | differ in signature. When using glibc, one can choose | ||
13 | between the two versions using feature test macros | ||
14 | _GNU_SOURCE and _POSIX_C_SOURCE. | ||
15 | |||
16 | Given libnl is built using the former, we always get the | ||
17 | glibc special version, and all code so far has been written | ||
18 | for that non-standard version. | ||
19 | |||
20 | Other C libraries like musl on the other hand only try | ||
21 | to be posix compliant, and only ever provide the posix | ||
22 | version of strerror_r(), which has a different signature. | ||
23 | |||
24 | The alternative is to use strerror_l() rather than | ||
25 | strerror_r() http://austingroupbugs.net/view.php?id=655 | ||
26 | - this will avoid the non-confirming versions issue | ||
27 | - strerror_l() is now recommended by POSIX to replace | ||
28 | strerror_r() usage | ||
29 | |||
30 | So rather than changing all uses of strerror_r() to be in | ||
31 | line with posix, we are going to switch to the recommended | ||
32 | interface strerror_l(). | ||
33 | |||
34 | Since strerror_l() is slightly more difficuly to use, we | ||
35 | add a little (private) wrapper that we can use from all | ||
36 | current callsites of strerror_r(). | ||
37 | |||
38 | Signed-off-by: André Draszik <adraszik@tycoint.com> | ||
39 | Reviewed-by: Stephane Ayotte <sayotte@tycoint.com> | ||
40 | Signed-off-by: Thomas Haller <thaller@redhat.com> | ||
41 | --- | ||
42 | Upstream-Status: Backport https://github.com/thom311/libnl/commit/683f27fbb68ca2028a7b3468f17164d484df2759 | ||
43 | include/Makefile.am | 1 + | ||
44 | include/netlink-private/utils.h | 17 +++++++++++++++++ | ||
45 | lib/utils.c | 24 ++++++++++++++++++++++++ | ||
46 | libnl-3.sym | 5 +++++ | ||
47 | 4 files changed, 47 insertions(+) | ||
48 | create mode 100644 include/netlink-private/utils.h | ||
49 | |||
50 | diff --git a/include/Makefile.am b/include/Makefile.am | ||
51 | index 804e984..f8b977a 100644 | ||
52 | --- a/include/Makefile.am | ||
53 | +++ b/include/Makefile.am | ||
54 | @@ -166,6 +166,7 @@ noinst_HEADERS = \ | ||
55 | netlink-private/socket.h \ | ||
56 | netlink-private/tc.h \ | ||
57 | netlink-private/types.h \ | ||
58 | + netlink-private/utils.h \ | ||
59 | netlink-private/cache-api.h \ | ||
60 | netlink-private/object-api.h \ | ||
61 | netlink-private/route/link/api.h \ | ||
62 | diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h | ||
63 | new file mode 100644 | ||
64 | index 0000000..77aadb3 | ||
65 | --- /dev/null | ||
66 | +++ b/include/netlink-private/utils.h | ||
67 | @@ -0,0 +1,17 @@ | ||
68 | +/* | ||
69 | + * netlink-private/utils.h Local Utility Functions | ||
70 | + * | ||
71 | + * This library is free software; you can redistribute it and/or | ||
72 | + * modify it under the terms of the GNU Lesser General Public | ||
73 | + * License as published by the Free Software Foundation version 2.1 | ||
74 | + * of the License. | ||
75 | + * | ||
76 | + * Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch> | ||
77 | + */ | ||
78 | + | ||
79 | +#ifndef NETLINK_UTILS_PRIV_H_ | ||
80 | +#define NETLINK_UTILS_PRIV_H_ | ||
81 | + | ||
82 | +extern const char * nl_strerror_l(int err); | ||
83 | + | ||
84 | +#endif | ||
85 | diff --git a/lib/utils.c b/lib/utils.c | ||
86 | index 61c3d95..c1c1b72 100644 | ||
87 | --- a/lib/utils.c | ||
88 | +++ b/lib/utils.c | ||
89 | @@ -25,10 +25,12 @@ | ||
90 | */ | ||
91 | |||
92 | #include <netlink-private/netlink.h> | ||
93 | +#include <netlink-private/utils.h> | ||
94 | #include <netlink/netlink.h> | ||
95 | #include <netlink/utils.h> | ||
96 | #include <linux/socket.h> | ||
97 | #include <stdlib.h> /* exit() */ | ||
98 | +#include <locale.h> | ||
99 | |||
100 | /** | ||
101 | * Global variable indicating the desired level of debugging output. | ||
102 | @@ -118,6 +120,28 @@ int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *)) | ||
103 | |||
104 | return 0; | ||
105 | } | ||
106 | + | ||
107 | +const char *nl_strerror_l(int err) | ||
108 | +{ | ||
109 | + int errno_save = errno; | ||
110 | + locale_t loc = newlocale(LC_MESSAGES_MASK, "", (locale_t)0); | ||
111 | + const char *buf; | ||
112 | + | ||
113 | + if (loc == (locale_t)0) { | ||
114 | + if (errno == ENOENT) | ||
115 | + loc = newlocale(LC_MESSAGES_MASK, | ||
116 | + "POSIX", (locale_t)0); | ||
117 | + } | ||
118 | + if (loc != (locale_t)0) { | ||
119 | + buf = strerror_l(err, loc); | ||
120 | + freelocale(loc); | ||
121 | + } else { | ||
122 | + buf = "newlocale() failed"; | ||
123 | + } | ||
124 | + | ||
125 | + errno = errno_save; | ||
126 | + return buf; | ||
127 | +} | ||
128 | /** @endcond */ | ||
129 | |||
130 | /** | ||
131 | diff --git a/libnl-3.sym b/libnl-3.sym | ||
132 | index 4e09bdd..9119e66 100644 | ||
133 | --- a/libnl-3.sym | ||
134 | +++ b/libnl-3.sym | ||
135 | @@ -351,3 +351,8 @@ libnl_3_2_28 { | ||
136 | global: | ||
137 | nl_object_diff64; | ||
138 | } libnl_3_2_27; | ||
139 | + | ||
140 | +libnl_3_2_29 { | ||
141 | +global: | ||
142 | + nl_strerror_l; | ||
143 | +} libnl_3_2_28; | ||
144 | -- | ||
145 | 2.9.3 | ||
146 | |||