1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../musl/ldso-glob.patch
5 # Copyright (C) 2019 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
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
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
28 #include <semaphore.h>
29 #include <sys/membarrier.h>
30 #include "pthread_impl.h"
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;
44 - /* Any negative value but -1 will inhibit
45 - * futher path search. */
47 + // via glob for wildcards
48 + if (snprintf(buf, buf_size, "%.*s", (int)l, s, name) < buf_size) {
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) {
64 + /* Any negative value but -1 will inhibit
65 + * futher path search. */