summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0005-src-basic-missing.h-check-for-missing-strndupa.patch
blob: 47ee2795a72fdf747a3f928b98a29a2bfbdf874f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
From 399fd3eda3045636a70da438a0fd1406cc332ed1 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 14:18:21 +0800
Subject: [PATCH 05/24] src/basic/missing.h: check for missing strndupa

include missing.h  for definition of strndupa

Upstream-Status: Inappropriate [musl specific]

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[Rebased for v242]
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
---
 meson.build                                |  1 +
 src/backlight/backlight.c                  |  1 +
 src/basic/env-util.c                       |  1 +
 src/basic/missing_stdlib.h                 | 12 ++++++++++++
 src/basic/mkdir.c                          |  1 +
 src/basic/parse-util.c                     |  1 +
 src/basic/proc-cmdline.c                   |  1 +
 src/basic/procfs-util.c                    |  1 +
 src/basic/time-util.c                      |  1 +
 src/core/dbus-cgroup.c                     |  1 +
 src/core/dbus-util.c                       |  1 +
 src/core/kmod-setup.c                      |  1 +
 src/core/service.c                         |  1 +
 src/journal/journalctl.c                   |  1 +
 src/libsystemd/sd-bus/bus-message.c        |  1 +
 src/libsystemd/sd-bus/bus-objects.c        |  1 +
 src/libsystemd/sd-bus/test-bus-benchmark.c |  1 +
 src/locale/keymap-util.c                   |  1 +
 src/nspawn/nspawn-settings.c               |  1 +
 src/shared/dns-domain.c                    |  1 +
 src/shared/journal-importer.c              |  1 +
 src/shared/logs-show.c                     |  1 +
 src/shared/pager.c                         |  1 +
 src/shared/path-lookup.c                   |  1 +
 src/shared/uid-range.c                     |  1 +
 src/socket-proxy/socket-proxyd.c           |  1 +
 src/test/test-hexdecoct.c                  |  1 +
 src/udev/udev-builtin-path_id.c            |  1 +
 src/udev/udev-rules.c                      |  1 +
 29 files changed, 40 insertions(+)

--- a/meson.build
+++ b/meson.build
@@ -572,6 +572,7 @@ foreach ident : [
                                  #include <unistd.h>'''],
         ['explicit_bzero' ,   '''#include <string.h>'''],
         ['reallocarray',      '''#include <malloc.h>'''],
+        ['strndupa' ,         '''#include <string.h>'''],
 ]
 
         have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -17,6 +17,7 @@
 #include "string-util.h"
 #include "strv.h"
 #include "util.h"
+#include "missing.h"
 
 static int find_pci_or_platform_parent(sd_device *device, sd_device **ret) {
         const char *subsystem, *sysname, *value;
--- a/src/basic/env-util.c
+++ b/src/basic/env-util.c
@@ -16,6 +16,7 @@
 #include "string-util.h"
 #include "strv.h"
 #include "utf8.h"
+#include "missing.h"
 
 #define VALID_CHARS_ENV_NAME                    \
         DIGITS LETTERS                          \
--- a/src/basic/missing_stdlib.h
+++ b/src/basic/missing_stdlib.h
@@ -11,3 +11,15 @@
 #    error "neither secure_getenv nor __secure_getenv are available"
 #  endif
 #endif
+
+/* string.h */
+#if ! HAVE_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
--- a/src/basic/mkdir.c
+++ b/src/basic/mkdir.c
@@ -14,6 +14,7 @@
 #include "stat-util.h"
 #include "stdio-util.h"
 #include "user-util.h"
+#include "missing.h"
 
 int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags, mkdir_func_t _mkdir) {
         struct stat st;
--- a/src/basic/parse-util.c
+++ b/src/basic/parse-util.c
@@ -19,6 +19,7 @@
 #include "process-util.h"
 #include "stat-util.h"
 #include "string-util.h"
+#include "missing.h"
 
 int parse_boolean(const char *v) {
         if (!v)
--- a/src/basic/proc-cmdline.c
+++ b/src/basic/proc-cmdline.c
@@ -15,6 +15,7 @@
 #include "string-util.h"
 #include "util.h"
 #include "virt.h"
+#include "missing.h"
 
 int proc_cmdline(char **ret) {
         const char *e;
--- a/src/basic/procfs-util.c
+++ b/src/basic/procfs-util.c
@@ -11,6 +11,7 @@
 #include "procfs-util.h"
 #include "stdio-util.h"
 #include "string-util.h"
+#include "missing.h"
 
 int procfs_tasks_get_limit(uint64_t *ret) {
         _cleanup_free_ char *value = NULL;
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -28,6 +28,7 @@
 #include "string-util.h"
 #include "strv.h"
 #include "time-util.h"
+#include "missing.h"
 
 static clockid_t map_clock_id(clockid_t c) {
 
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -15,6 +15,7 @@
 #include "fileio.h"
 #include "limits-util.h"
 #include "path-util.h"
+#include "missing.h"
 
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy);
 
--- a/src/core/dbus-util.c
+++ b/src/core/dbus-util.c
@@ -7,6 +7,7 @@
 #include "unit-printf.h"
 #include "user-util.h"
 #include "unit.h"
+#include "missing.h"
 
 int bus_property_get_triggered_unit(
                 sd_bus *bus,
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -11,6 +11,7 @@
 #include "kmod-setup.h"
 #include "macro.h"
 #include "string-util.h"
+#include "missing.h"
 
 #if HAVE_KMOD
 #include <libkmod.h>
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -42,6 +42,7 @@
 #include "unit.h"
 #include "utf8.h"
 #include "util.h"
+#include "missing.h"
 
 static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = {
         [SERVICE_DEAD] = UNIT_INACTIVE,
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -67,6 +67,7 @@
 #include "tmpfile-util.h"
 #include "unit-name.h"
 #include "user-util.h"
+#include "missing.h"
 
 #define DEFAULT_FSS_INTERVAL_USEC (15*USEC_PER_MINUTE)
 
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -21,6 +21,7 @@
 #include "strv.h"
 #include "time-util.h"
 #include "utf8.h"
+#include "missing.h"
 
 static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored);
 
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -13,6 +13,7 @@
 #include "set.h"
 #include "string-util.h"
 #include "strv.h"
+#include "missing.h"
 
 static int node_vtable_get_userdata(
                 sd_bus *bus,
--- a/src/libsystemd/sd-bus/test-bus-benchmark.c
+++ b/src/libsystemd/sd-bus/test-bus-benchmark.c
@@ -14,6 +14,7 @@
 #include "missing_resource.h"
 #include "time-util.h"
 #include "util.h"
+#include "missing.h"
 
 #define MAX_SIZE (2*1024*1024)
 
--- a/src/locale/keymap-util.c
+++ b/src/locale/keymap-util.c
@@ -23,6 +23,7 @@
 #include "string-util.h"
 #include "strv.h"
 #include "tmpfile-util.h"
+#include "missing.h"
 
 static bool startswith_comma(const char *s, const char *prefix) {
         s = startswith(s, prefix);
--- a/src/nspawn/nspawn-settings.c
+++ b/src/nspawn/nspawn-settings.c
@@ -16,6 +16,7 @@
 #include "strv.h"
 #include "user-util.h"
 #include "util.h"
+#include "missing.h"
 
 Settings *settings_new(void) {
         Settings *s;
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -24,6 +24,7 @@
 #include "string-util.h"
 #include "strv.h"
 #include "utf8.h"
+#include "missing.h"
 
 int dns_label_unescape(const char **name, char *dest, size_t sz, DNSLabelFlags flags) {
         const char *n;
--- a/src/shared/journal-importer.c
+++ b/src/shared/journal-importer.c
@@ -13,6 +13,7 @@
 #include "parse-util.h"
 #include "string-util.h"
 #include "unaligned.h"
+#include "missing.h"
 
 enum {
         IMPORTER_STATE_LINE = 0,    /* waiting to read, or reading line */
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -38,6 +38,7 @@
 #include "time-util.h"
 #include "utf8.h"
 #include "util.h"
+#include "missing.h"
 
 /* up to three lines (each up to 100 characters) or 300 characters, whichever is less */
 #define PRINT_LINE_THRESHOLD 3
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -25,6 +25,7 @@
 #include "strv.h"
 #include "terminal-util.h"
 #include "util.h"
+#include "missing.h"
 
 static pid_t pager_pid = 0;
 
--- a/src/shared/path-lookup.c
+++ b/src/shared/path-lookup.c
@@ -20,6 +20,7 @@
 #include "tmpfile-util.h"
 #include "user-util.h"
 #include "util.h"
+#include "missing.h"
 
 int xdg_user_runtime_dir(char **ret, const char *suffix) {
         const char *e;
--- a/src/shared/uid-range.c
+++ b/src/shared/uid-range.c
@@ -9,6 +9,7 @@
 #include "sort-util.h"
 #include "uid-range.h"
 #include "user-util.h"
+#include "missing.h"
 
 static bool uid_range_intersect(UidRange *range, uid_t start, uid_t nr) {
         assert(range);
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -28,6 +28,7 @@
 #include "socket-util.h"
 #include "string-util.h"
 #include "util.h"
+#include "missing.h"
 
 #define BUFFER_SIZE (256 * 1024)
 
--- a/src/test/test-hexdecoct.c
+++ b/src/test/test-hexdecoct.c
@@ -6,6 +6,7 @@
 #include "hexdecoct.h"
 #include "macro.h"
 #include "string-util.h"
+#include "missing.h"
 
 static void test_hexchar(void) {
         assert_se(hexchar(0xa) == 'a');
--- a/src/udev/udev-builtin-path_id.c
+++ b/src/udev/udev-builtin-path_id.c
@@ -23,6 +23,7 @@
 #include "strv.h"
 #include "sysexits.h"
 #include "udev-builtin.h"
+#include "missing.h"
 
 _printf_(2,3)
 static void path_prepend(char **path, const char *fmt, ...) {
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -40,6 +40,7 @@
 #include "udev.h"
 #include "user-util.h"
 #include "util.h"
+#include "missing.h"
 
 #define PREALLOC_TOKEN          2048
 #define RULES_DIRS (const char* const*) CONF_PATHS_STRV("udev/rules.d")
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -27,6 +27,7 @@
 #include "hostname-util.h"
 #include "login-util.h"
 #include "macro.h"
+#include "missing.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "process-util.h"