Skip to content
Snippets Groups Projects
Commit edc1ec2c authored by Timo Teräs's avatar Timo Teräs
Browse files

main/musl: align with upstream git, fixes for timezone handling

parent a1e8a7a1
No related branches found
No related tags found
No related merge requests found
From 476cd1d96560aaf7f210319597556e7fbcd60469 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Fri, 18 Apr 2014 17:38:35 -0400
Subject: [PATCH] fix false negatives with periodic needles in strstr, wcsstr,
and memmem
in cases where the memorized match range from the right factor
exceeded the length of the left factor, it was wrongly treated as a
mismatch rather than a match.
issue reported by Yves Bastide.
---
src/string/memmem.c | 2 +-
src/string/strstr.c | 2 +-
src/string/wcsstr.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/string/memmem.c b/src/string/memmem.c
index a5a249f..3b1ae18 100644
--- a/src/string/memmem.c
+++ b/src/string/memmem.c
@@ -120,7 +120,7 @@ static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const
}
/* Compare left half */
for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
- if (k == mem) return (char *)h;
+ if (k <= mem) return (char *)h;
h += p;
mem = mem0;
}
diff --git a/src/string/strstr.c b/src/string/strstr.c
index 915c0a2..cd06912 100644
--- a/src/string/strstr.c
+++ b/src/string/strstr.c
@@ -130,7 +130,7 @@ static char *twoway_strstr(const unsigned char *h, const unsigned char *n)
}
/* Compare left half */
for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
- if (k == mem) return (char *)h;
+ if (k <= mem) return (char *)h;
h += p;
mem = mem0;
}
diff --git a/src/string/wcsstr.c b/src/string/wcsstr.c
index 3e28e28..4caaef3 100644
--- a/src/string/wcsstr.c
+++ b/src/string/wcsstr.c
@@ -84,7 +84,7 @@ static wchar_t *twoway_wcsstr(const wchar_t *h, const wchar_t *n)
}
/* Compare left half */
for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
- if (k == mem) return (wchar_t *)h;
+ if (k <= mem) return (wchar_t *)h;
h += p;
mem = mem0;
}
--
1.9.2
diff --git a/arch/i386/syscall_arch.h b/arch/i386/syscall_arch.h
index b19f27e..838d0a2 100644
--- a/arch/i386/syscall_arch.h
+++ b/arch/i386/syscall_arch.h
@@ -51,25 +51,3 @@ static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a
__asm__ __volatile__ ("push %6 ; call __vsyscall6 ; add $4,%%esp" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4), "g"(0+(long[]){a5, a6}) : "memory");
return __ret;
}
-
-
-#define __SC_socket 1
-#define __SC_bind 2
-#define __SC_connect 3
-#define __SC_listen 4
-#define __SC_accept 5
-#define __SC_getsockname 6
-#define __SC_getpeername 7
-#define __SC_socketpair 8
-#define __SC_send 9
-#define __SC_recv 10
-#define __SC_sendto 11
-#define __SC_recvfrom 12
-#define __SC_shutdown 13
-#define __SC_setsockopt 14
-#define __SC_getsockopt 15
-#define __SC_sendmsg 16
-#define __SC_recvmsg 17
-#define __SC_accept4 18
-#define __SC_recvmmsg 19
-#define __SC_sendmmsg 20
diff --git a/arch/powerpc/syscall_arch.h b/arch/powerpc/syscall_arch.h
index 21c1134..7a6b6b7 100644
--- a/arch/powerpc/syscall_arch.h
+++ b/arch/powerpc/syscall_arch.h
@@ -39,21 +39,3 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
{
return (__syscall)(n, a, b, c, d, e, f);
}
-
-#define __SC_socket 1
-#define __SC_bind 2
-#define __SC_connect 3
-#define __SC_listen 4
-#define __SC_accept 5
-#define __SC_getsockname 6
-#define __SC_getpeername 7
-#define __SC_socketpair 8
-#define __SC_send 9
-#define __SC_recv 10
-#define __SC_sendto 11
-#define __SC_recvfrom 12
-#define __SC_shutdown 13
-#define __SC_setsockopt 14
-#define __SC_getsockopt 15
-#define __SC_sendmsg 16
-#define __SC_recvmsg 17
diff --git a/include/unistd.h b/include/unistd.h
index bf10a6d..a906552 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -177,6 +177,7 @@ void endusershell(void);
char *getusershell(void);
int acct(const char *);
long syscall(long, ...);
+int execvpe(const char *, char *const [], char *const []);
#endif
#ifdef _GNU_SOURCE
diff --git a/src/env/__init_security.c b/src/env/__init_security.c
deleted file mode 100644
index da5ae94..0000000
--- a/src/env/__init_security.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <elf.h>
-#include <poll.h>
-#include <fcntl.h>
-#include "syscall.h"
-#include "libc.h"
-#include "atomic.h"
-
-static void dummy(void *ent)
-{
-}
-weak_alias(dummy, __init_ssp);
-
-void __init_security(size_t *aux)
-{
- struct pollfd pfd[3] = { {.fd=0}, {.fd=1}, {.fd=2} };
- int i;
-
- __init_ssp((void *)aux[AT_RANDOM]);
-
- if (aux[AT_UID]==aux[AT_EUID] && aux[AT_GID]==aux[AT_EGID]
- && !aux[AT_SECURE]) return;
-
- __syscall(SYS_poll, pfd, 3, 0);
- for (i=0; i<3; i++) if (pfd[i].revents&POLLNVAL)
- if (__syscall(SYS_open, "/dev/null", O_RDWR|O_LARGEFILE)<0)
- a_crash();
- libc.secure = 1;
-}
diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c
index ac37492..3498afb 100644
--- a/src/env/__libc_start_main.c
+++ b/src/env/__libc_start_main.c
@@ -1,8 +1,11 @@
#include <elf.h>
+#include <poll.h>
+#include <fcntl.h>
+#include "syscall.h"
+#include "atomic.h"
#include "libc.h"
void __init_tls(size_t *);
-void __init_security(size_t *);
#ifndef SHARED
static void dummy() {}
@@ -11,11 +14,17 @@ extern void (*const __init_array_start)() __attribute__((weak));
extern void (*const __init_array_end)() __attribute__((weak));
#endif
+static void dummy1(void *p) {}
+weak_alias(dummy1, __init_ssp);
+
#define AUX_CNT 38
extern size_t __hwcap, __sysinfo;
extern char *__progname, *__progname_full;
+#ifndef SHARED
+static
+#endif
void __init_libc(char **envp, char *pn)
{
size_t i, *auxv, aux[AUX_CNT] = { 0 };
@@ -33,7 +42,17 @@ void __init_libc(char **envp, char *pn)
}
__init_tls(aux);
- __init_security(aux);
+ __init_ssp((void *)aux[AT_RANDOM]);
+
+ if (aux[AT_UID]==aux[AT_EUID] && aux[AT_GID]==aux[AT_EGID]
+ && !aux[AT_SECURE]) return;
+
+ struct pollfd pfd[3] = { {.fd=0}, {.fd=1}, {.fd=2} };
+ __syscall(SYS_poll, pfd, 3, 0);
+ for (i=0; i<3; i++) if (pfd[i].revents&POLLNVAL)
+ if (__syscall(SYS_open, "/dev/null", O_RDWR|O_LARGEFILE)<0)
+ a_crash();
+ libc.secure = 1;
}
int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)
diff --git a/src/internal/syscall.h b/src/internal/syscall.h
index dcfae00..914b0d1 100644
--- a/src/internal/syscall.h
+++ b/src/internal/syscall.h
@@ -164,3 +164,26 @@ long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...),
#endif
#endif
+
+/* socketcall calls */
+
+#define __SC_socket 1
+#define __SC_bind 2
+#define __SC_connect 3
+#define __SC_listen 4
+#define __SC_accept 5
+#define __SC_getsockname 6
+#define __SC_getpeername 7
+#define __SC_socketpair 8
+#define __SC_send 9
+#define __SC_recv 10
+#define __SC_sendto 11
+#define __SC_recvfrom 12
+#define __SC_shutdown 13
+#define __SC_setsockopt 14
+#define __SC_getsockopt 15
+#define __SC_sendmsg 16
+#define __SC_recvmsg 17
+#define __SC_accept4 18
+#define __SC_recvmmsg 19
+#define __SC_sendmmsg 20
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 1517281..1cb3fb4 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -1055,12 +1055,31 @@ void *__dynlink(int argc, char **argv)
size_t l = strlen(ldname);
if (l >= 3 && !strcmp(ldname+l-3, "ldd")) ldd_mode = 1;
*argv++ = (void *)-1;
- if (argv[0] && !strcmp(argv[0], "--")) *argv++ = (void *)-1;
+ while (argv[0] && argv[0][0]=='-' && argv[0][1]=='-') {
+ char *opt = argv[0]+2;
+ *argv++ = (void *)-1;
+ if (!*opt) {
+ break;
+ } else if (!memcmp(opt, "list", 5)) {
+ ldd_mode = 1;
+ } else if (!memcmp(opt, "library-path", 12)) {
+ if (opt[12]=='=') env_path = opt+13;
+ else if (opt[12]) *argv = 0;
+ else if (*argv) env_path = *argv++;
+ } else if (!memcmp(opt, "preload", 7)) {
+ if (opt[7]=='=') env_preload = opt+8;
+ else if (opt[7]) *argv = 0;
+ else if (*argv) env_preload = *argv++;
+ } else {
+ argv[0] = 0;
+ }
+ argv[-1] = (void *)-1;
+ }
if (!argv[0]) {
dprintf(2, "musl libc\n"
"Version %s\n"
"Dynamic Program Loader\n"
- "Usage: %s [--] pathname%s\n",
+ "Usage: %s [options] [--] pathname%s\n",
__libc_get_version(), ldname,
ldd_mode ? "" : " [args]");
_exit(1);
diff --git a/src/process/execvp.c b/src/process/execvp.c
index 0a33e42..7d32200 100644
--- a/src/process/execvp.c
+++ b/src/process/execvp.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <errno.h>
#include <limits.h>
+#include "libc.h"
extern char **__environ;
@@ -47,3 +48,5 @@ int execvp(const char *file, char *const argv[])
{
return __execvpe(file, argv, __environ);
}
+
+weak_alias(__execvpe, execvpe);
diff --git a/src/string/memmem.c b/src/string/memmem.c
index a5a249f..3b1ae18 100644
--- a/src/string/memmem.c
+++ b/src/string/memmem.c
@@ -120,7 +120,7 @@ static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const
}
/* Compare left half */
for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
- if (k == mem) return (char *)h;
+ if (k <= mem) return (char *)h;
h += p;
mem = mem0;
}
diff --git a/src/string/strstr.c b/src/string/strstr.c
index 915c0a2..cd06912 100644
--- a/src/string/strstr.c
+++ b/src/string/strstr.c
@@ -130,7 +130,7 @@ static char *twoway_strstr(const unsigned char *h, const unsigned char *n)
}
/* Compare left half */
for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
- if (k == mem) return (char *)h;
+ if (k <= mem) return (char *)h;
h += p;
mem = mem0;
}
diff --git a/src/string/wcsstr.c b/src/string/wcsstr.c
index 3e28e28..4caaef3 100644
--- a/src/string/wcsstr.c
+++ b/src/string/wcsstr.c
@@ -84,7 +84,7 @@ static wchar_t *twoway_wcsstr(const wchar_t *h, const wchar_t *n)
}
/* Compare left half */
for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
- if (k == mem) return (wchar_t *)h;
+ if (k <= mem) return (wchar_t *)h;
h += p;
mem = mem0;
}
diff --git a/src/time/__tz.c b/src/time/__tz.c
index 9d56a61..6d7173c 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -121,7 +121,7 @@ int __munmap(void *, size_t);
static void do_tzset()
{
char buf[NAME_MAX+25], *pathname=buf+24;
- const char *try, *s;
+ const char *try, *s, *p;
const unsigned char *map = 0;
size_t i;
static const char search[] =
@@ -147,19 +147,16 @@ static void do_tzset()
}
if (old_tz) memcpy(old_tz, s, i+1);
- if (*s == ':') s++;
-
/* Non-suid can use an absolute tzfile pathname or a relative
* pathame beginning with "."; in secure mode, only the
* standard path will be searched. */
- if (*s == '/' || *s == '.') {
- if (!libc.secure) map = __map_file(s, &map_size);
- } else {
- for (i=0; s[i] && s[i]!=','; i++) {
- if (s[i]=='/') {
- size_t l = strlen(s);
- if (l > NAME_MAX || strchr(s, '.'))
- break;
+ if (*s == ':' || ((p=strchr(s, '/')) && !memchr(s, ',', p-s))) {
+ if (*s == ':') s++;
+ if (*s == '/' || *s == '.') {
+ if (!libc.secure) map = __map_file(s, &map_size);
+ } else {
+ size_t l = strlen(s);
+ if (l <= NAME_MAX && !strchr(s, '.')) {
memcpy(pathname, s, l+1);
pathname[l] = 0;
for (try=search; !map && *try; try+=l+1) {
@@ -167,9 +164,14 @@ static void do_tzset()
memcpy(pathname-l, try, l);
map = __map_file(pathname-l, &map_size);
}
- break;
}
}
+ if (!map) s = __gmt;
+ }
+ if (map && (map_size < 44 || memcmp(map, "TZif", 4))) {
+ __munmap((void *)map, map_size);
+ map = 0;
+ s = __gmt;
}
zi = map;
From 4776cf82a9367ff51883af243a219d45da35d3b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Wed, 23 Apr 2014 09:11:46 +0300
Subject: [PATCH] default to localtime timezone if TZ is undefined
the rest of the logic fallsback to GMT if it does not exist
(since musl commit 0f2315b4af1c58cbfb7c7f9da69b495cd146cc18)
---
src/time/__tz.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/time/__tz.c b/src/time/__tz.c
index 6d7173c..4184b60 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -128,7 +128,7 @@ static void do_tzset()
"/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0";
s = getenv("TZ");
- if (!s || !*s) s = __gmt;
+ if (!s || !*s) s = ":localtime";
if (old_tz && !strcmp(s, old_tz)) return;
--
1.9.2
......@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.0
pkgrel=2
pkgrel=3
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
......@@ -14,9 +14,10 @@ install=""
subpackages="$pkgname-dev $pkgname-utils"
[ "${CTARGET#*musl}" = "$CTARGET" ] && subpackages="$subpackages musl-gcc:crosstool"
source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
0001-fix-false-negatives-with-periodic-needles-in-strstr-.patch
0001-v1.1.0-to-c3d9d172.patch
1001-add-basic-dns-record-parsing-functions.patch
1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
2001-default-to-localtime-timezone-if-TZ-is-undefined.patch
getopt_long.c
__stack_chk_fail_local.c
......@@ -100,7 +101,7 @@ package() {
}
utils() {
replaces="uclibc-utils"
depends="!uclibc-utils !libiconv"
license="MIT BSD GPL2+"
mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/sbin
......@@ -125,27 +126,30 @@ crosstool() {
}
md5sums="c2118c3b6afc77f46a0b23a38a8c3080 musl-1.1.0.tar.gz
68aad2b2b61da0d2f189d29724a9f07f 0001-fix-false-negatives-with-periodic-needles-in-strstr-.patch
1789d43fa0c5f76184cdbaff18a429cb 0001-v1.1.0-to-c3d9d172.patch
a3810683ef61ac27e2f6ec9801280c81 1001-add-basic-dns-record-parsing-functions.patch
83c3bd2a50b1de5ef948704d3f4e0583 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
e936297ceb484b2160a4cd8a3a4eb291 2001-default-to-localtime-timezone-if-TZ-is-undefined.patch
61c6c1e84ed1df82abbe6d75e90cf21c getopt_long.c
0df687757221bbb0fc1aa67f1bd646f9 __stack_chk_fail_local.c
dae8a31f47488273d8465c785bd77a00 getconf.c
2b941c4251cac44988a4abfc50e21267 getent.c
170ce44d0eca4bcfebdf402f21af5f71 iconv.c"
sha256sums="de1b43019e5361d7577e5e0213e9dde591853e9da5d4a7cd75e2e0d78bf60820 musl-1.1.0.tar.gz
d55586f436af5ea2555f848b2e1a1aeed89786d3ec76b4cedcceec3d78a64d31 0001-fix-false-negatives-with-periodic-needles-in-strstr-.patch
6ce417df2acedd6973580ae7985b337fa6ba58bd26752a01c5dcab1f2ce8925c 0001-v1.1.0-to-c3d9d172.patch
758390768b1bc4159d56908ca332b9640cd0552ed3b4b2b8d4a6d499c54c11a1 1001-add-basic-dns-record-parsing-functions.patch
1c25880095e869b827f02997e864fdf4bf157a4e923e52d97dbd05e657aedb70 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
60d7aa78040ee664681e507475129f76e445291863137e568c9a3d11ae8436ce 2001-default-to-localtime-timezone-if-TZ-is-undefined.patch
d9b644ec20bc33e81a7c52b9fcf7973d835923a69faf50f03db45534b811bd96 getopt_long.c
299a7d75a09de3e2e11e7fb4acc3182e4a14e868093d2f30938fce9bfcff13da __stack_chk_fail_local.c
e3d1e1f82d1319d9be4726a32dfbe08ab8c23aceaa5e6b667cb391f70a467a1e getconf.c
68373a55e89ce85c562d941ccf588337d6cc6c9c17689d695f65cd7607134bbe getent.c
c24f1da0bdb201d0689efcf257d2146209cb036c313436d76ca80984ace01b0c iconv.c"
sha512sums="72dab085fa56a2f02d407074b9a4c1d409624df74924ed385b174a767113aa0a4112bd22d3eaf465b31a14b8e60a15997d6042421994673977de306ee8738b3d musl-1.1.0.tar.gz
d12c4ba139c43650e7a7aa70df23da2b9d5786be199c3103d2c246718d296cbde593d90743ee4ff8681c64a129be85a8d12c0b819da092d130e67dd00fc54482 0001-fix-false-negatives-with-periodic-needles-in-strstr-.patch
72be49c7b0598954f5ec2f9377d1848f3d22d018f97544f5c9ea96a8cd6e7b654365703832bcbb3e98a8b2d96e445a4fb0a0573ce5355ccd8a03dbeb9acc5dbc 0001-v1.1.0-to-c3d9d172.patch
dad965258daf69371b844f76bfe5a914b0eca0ca76f3fc340b8fd7acf598b5f87bbe6d68b1f43ed0293ee0ed3bfd85d5173ccc169aa6265646248d5b8a906708 1001-add-basic-dns-record-parsing-functions.patch
72cf33738d2cf31f6ec02312bc494d754c17470b519172bb8bd7e2e29ac3b119023088a2b3fbc0dbc2fddd0078ccbae62096106cae361f8c31d6a9950043af25 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
8d4cae760895a18e83b5fcbdc925705a6dd98acd2270562ee6c905363096a4111cf3aa324b52a16066e30bddc9ab104883e2b25b5c68396ea27f1c50cb939f0a 2001-default-to-localtime-timezone-if-TZ-is-undefined.patch
140f3f20d30bd95ebce8c41b8cc7f616c6cbedf4ea06c729c21014e74f6043796825cc40ebc5180620ea38173afdba23f09ebf6d8b11fa05440b14d23764fca9 getopt_long.c
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c
04ead14ff557d71153457b7f55c4b3ecb7594f91e01a9319a6ad0056010570cbc69680d82a7bf9c977c8bb382cfbb7cd6bf79f8fbceadf0a0f9f77812f32a324 getconf.c
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment