* added python-wheel (0.42.0) - The official binary distribution format for Python
[t2sde.git] / package / base / musl / ldso-glob.patch
blob604d6bbd2e2c2b3b20443e516933762a745cc7a8
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../musl/ldso-glob.patch
5 # Copyright (C) 2019 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 Wildcard expansion (glob) patch for musl.
19 - René Rebe <rene@exactcode.de>
21 --- musl-1.1.23/ldso/dynlink.c.vanilla 2019-10-01 15:54:50.216000000 +0200
22 +++ musl-1.1.23/ldso/dynlink.c 2019-10-01 17:00:28.384000000 +0200
23 @@ -18,6 +18,7 @@
24 #include <pthread.h>
25 #include <ctype.h>
26 #include <dlfcn.h>
27 +#include <glob.h>
28 #include <semaphore.h>
29 #include <sys/membarrier.h>
30 #include "pthread_impl.h"
31 @@ -777,19 +778,31 @@
32 s += strspn(s, ":\n");
33 l = strcspn(s, ":\n");
34 if (l-1 >= INT_MAX) return -1;
35 - if (snprintf(buf, buf_size, "%.*s/%s", (int)l, s, name) < buf_size) {
36 - if ((fd = open(buf, O_RDONLY|O_CLOEXEC))>=0) return fd;
37 - switch (errno) {
38 - case ENOENT:
39 - case ENOTDIR:
40 - case EACCES:
41 - case ENAMETOOLONG:
42 - break;
43 - default:
44 - /* Any negative value but -1 will inhibit
45 - * futher path search. */
46 - return -2;
47 + // via glob for wildcards
48 + if (snprintf(buf, buf_size, "%.*s", (int)l, s, name) < buf_size) {
49 + glob_t result;
50 + int ret = glob(buf, GLOB_ONLYDIR, NULL, &result);
51 + for (int i = 0; ret == 0 && i < result.gl_pathc; ++i) {
52 + if (snprintf(buf, buf_size, "%s/%s", result.gl_pathv[i], name) < buf_size) {
53 + if ((fd = open(buf, O_RDONLY|O_CLOEXEC))>=0) {
54 + globfree(&result);
55 + return fd;
56 + }
57 + switch (errno) {
58 + case ENOENT:
59 + case ENOTDIR:
60 + case EACCES:
61 + case ENAMETOOLONG:
62 + break;
63 + default:
64 + /* Any negative value but -1 will inhibit
65 + * futher path search. */
66 + globfree(&result);
67 + return -2;
68 + }
69 + }
71 + globfree(&result);
73 s += l;