# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # T2 SDE: package/.../musl/ldso-glob.patch # Copyright (C) 2019 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-END --- Wildcard expansion (glob) patch for musl. - René Rebe --- musl-1.1.23/ldso/dynlink.c.vanilla 2019-10-01 15:54:50.216000000 +0200 +++ musl-1.1.23/ldso/dynlink.c 2019-10-01 17:00:28.384000000 +0200 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include "pthread_impl.h" @@ -777,19 +778,31 @@ s += strspn(s, ":\n"); l = strcspn(s, ":\n"); if (l-1 >= INT_MAX) return -1; - if (snprintf(buf, buf_size, "%.*s/%s", (int)l, s, name) < buf_size) { - if ((fd = open(buf, O_RDONLY|O_CLOEXEC))>=0) return fd; - switch (errno) { - case ENOENT: - case ENOTDIR: - case EACCES: - case ENAMETOOLONG: - break; - default: - /* Any negative value but -1 will inhibit - * futher path search. */ - return -2; + // via glob for wildcards + if (snprintf(buf, buf_size, "%.*s", (int)l, s, name) < buf_size) { + glob_t result; + int ret = glob(buf, GLOB_ONLYDIR, NULL, &result); + for (int i = 0; ret == 0 && i < result.gl_pathc; ++i) { + if (snprintf(buf, buf_size, "%s/%s", result.gl_pathv[i], name) < buf_size) { + if ((fd = open(buf, O_RDONLY|O_CLOEXEC))>=0) { + globfree(&result); + return fd; + } + switch (errno) { + case ENOENT: + case ENOTDIR: + case EACCES: + case ENAMETOOLONG: + break; + default: + /* Any negative value but -1 will inhibit + * futher path search. */ + globfree(&result); + return -2; + } + } } + globfree(&result); } s += l; }