Commit 8b244c53 authored by Timo Teräs's avatar Timo Teräs

main/musl: cherry-pick upstream fixes

fixes #5282
parent 112ce383
From 3cdbfb99c3beda1e04efcc94f0af2abc8dc5d4ad Mon Sep 17 00:00:00 2001
From: Ron Yorston <rmy@frippery.org>
Date: Fri, 15 Jan 2016 09:39:44 +0000
Subject: [PATCH] fix if_nametoindex return value when socket open fails
The return value of if_nametoindex is unsigned; it should return 0
on error.
---
src/network/if_nametoindex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/network/if_nametoindex.c b/src/network/if_nametoindex.c
index cb6ec05..331413c 100644
--- a/src/network/if_nametoindex.c
+++ b/src/network/if_nametoindex.c
@@ -10,7 +10,7 @@ unsigned if_nametoindex(const char *name)
struct ifreq ifr;
int fd, r;
- if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return -1;
+ if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return 0;
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
r = ioctl(fd, SIOCGIFINDEX, &ifr);
__syscall(SYS_close, fd);
--
2.7.4
From 6d70c08a2c37745df637b231711f6dec79dbc6e1 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 2 Mar 2016 00:34:51 -0500
Subject: [PATCH] handle non-matching address family entries in hosts file
name_from_hosts failed to account for the possibility of an address
family error from name_from_numeric, wrongly counting such a return as
success and using the uninitialized address data as part of the
results passed up to the caller.
non-matching address family entries cannot simply be ignored or
results would be inconsistent with respect to whether AF_UNSPEC or a
specific address family is queried. instead, record that a
non-matching entry was seen, and fail the lookup with EAI_NONAME of no
matching-family entries are found.
---
src/network/lookup_name.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/network/lookup_name.c b/src/network/lookup_name.c
index a26ad53..86f90ac 100644
--- a/src/network/lookup_name.c
+++ b/src/network/lookup_name.c
@@ -49,7 +49,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati
{
char line[512];
size_t l = strlen(name);
- int cnt = 0;
+ int cnt = 0, badfam = 0;
unsigned char _buf[1032];
FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf);
if (!f) switch (errno) {
@@ -71,8 +71,16 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati
/* Isolate IP address to parse */
for (p=line; *p && !isspace(*p); p++);
*p++ = 0;
- if (name_from_numeric(buf+cnt, line, family))
+ switch (name_from_numeric(buf+cnt, line, family)) {
+ case 1:
cnt++;
+ break;
+ case 0:
+ continue;
+ default:
+ badfam = EAI_NONAME;
+ continue;
+ }
/* Extract first name as canonical name */
for (; *p && isspace(*p); p++);
@@ -81,7 +89,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati
if (is_valid_hostname(p)) memcpy(canon, p, z-p+1);
}
__fclose_ca(f);
- return cnt;
+ return cnt ? cnt : badfam;
}
struct dpc_ctx {
--
2.7.4
From b023c03b574acdfd73418314a5dcaa83e5cea5a0 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Fri, 4 Mar 2016 21:23:33 +0000
Subject: [PATCH] math: fix expf(-NAN) and exp2f(-NAN) to return -NAN instead
of 0
expf(-NAN) was treated as expf(-large) which unconditionally
returns +0, so special case +-NAN.
reported by Petr Hosek.
---
src/math/exp2f.c | 2 ++
src/math/expf.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/src/math/exp2f.c b/src/math/exp2f.c
index cf6126e..296b634 100644
--- a/src/math/exp2f.c
+++ b/src/math/exp2f.c
@@ -91,6 +91,8 @@ float exp2f(float x)
/* Filter out exceptional cases. */
ix = u.i & 0x7fffffff;
if (ix > 0x42fc0000) { /* |x| > 126 */
+ if (ix > 0x7f800000) /* NaN */
+ return x;
if (u.i >= 0x43000000 && u.i < 0x80000000) { /* x >= 128 */
x *= 0x1p127f;
return x;
diff --git a/src/math/expf.c b/src/math/expf.c
index 16e9afe..feee2b0 100644
--- a/src/math/expf.c
+++ b/src/math/expf.c
@@ -39,6 +39,8 @@ float expf(float x)
/* special cases */
if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */
+ if (hx > 0x7f800000) /* NaN */
+ return x;
if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */
/* overflow */
x *= 0x1p127f;
--
2.7.4
From 9543656cc32fda48fc463f332ee20e91eed2b768 Mon Sep 17 00:00:00 2001
From: Alexander Monakov <amonakov@ispras.ru>
Date: Sun, 6 Mar 2016 20:22:38 +0300
Subject: [PATCH] env: avoid leaving dangling pointers in __env_map
This is the minimal fix for __putenv leaving a pointer to freed heap
storage in __env_map array, which could later on lead to errors such
as double-free.
---
src/env/putenv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/env/putenv.c b/src/env/putenv.c
index 4042869..7153042 100644
--- a/src/env/putenv.c
+++ b/src/env/putenv.c
@@ -30,6 +30,7 @@ int __putenv(char *s, int a)
}
} else {
free(__env_map[j]);
+ __env_map[j] = s;
}
}
}
--
2.7.4
From 4aac019a0efd59011a48d031ad046c934c7e8365 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 16 Mar 2016 16:35:22 -0400
Subject: [PATCH] fix padding string formats to width in wide printf variants
the idiom fprintf(f, "%.*s", n, "") was wrongly used in vfwprintf as a
means of producing n spaces; instead it produces no output. the
correct form is fprintf(f, "%*s", n, ""), using width instead of
precision, since for %s the later is a maximum rather than a minimum.
---
src/stdio/vfwprintf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
index f06d5ae..f9f1ecf 100644
--- a/src/stdio/vfwprintf.c
+++ b/src/stdio/vfwprintf.c
@@ -288,9 +288,9 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
z = wmemchr(a, 0, p);
if (z) p=z-a;
if (w<p) w=p;
- if (!(fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
+ if (!(fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
out(f, a, p);
- if ((fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
+ if ((fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
l=w;
continue;
case 'm':
@@ -303,14 +303,14 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
if (i<0) return -1;
p=l;
if (w<p) w=p;
- if (!(fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
+ if (!(fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
bs = arg.p;
while (l--) {
i=mbtowc(&wc, bs, MB_LEN_MAX);
bs+=i;
fputwc(wc, f);
}
- if ((fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
+ if ((fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
l=w;
continue;
}
--
2.7.4
From d378d05848f745598216259b6dba7c70f0e90300 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Tue, 22 Mar 2016 16:27:51 +0200
Subject: [PATCH] fix gethostbyaddr_r to fill struct hostent.h_length as
appropriate
---
src/network/gethostbyaddr_r.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/network/gethostbyaddr_r.c b/src/network/gethostbyaddr_r.c
index 66e0330..0f1e61a 100644
--- a/src/network/gethostbyaddr_r.c
+++ b/src/network/gethostbyaddr_r.c
@@ -64,6 +64,7 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af,
}
h->h_addrtype = af;
+ h->h_length = l;
h->h_name = h->h_aliases[0];
*res = h;
return 0;
--
2.7.4
......@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.12
pkgrel=2
pkgrel=3
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
......@@ -35,6 +35,12 @@ source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
0021-avoid-updating-caller-s-size-when-getdelim-fails-to-.patch
0022-fix-overly-pessimistic-realloc-strategy-in-getdelim.patch
0023-add-missing-protocols-to-protoent-lookup-functions.patch
0024-fix-if_nametoindex-return-value-when-socket-open-fai.patch
0025-handle-non-matching-address-family-entries-in-hosts-.patch
0026-math-fix-expf-NAN-and-exp2f-NAN-to-return-NAN-instea.patch
0027-env-avoid-leaving-dangling-pointers-in-__env_map.patch
0028-fix-padding-string-formats-to-width-in-wide-printf-v.patch
1001-fix-gethostbyaddr_r-to-fill-struct-hostent.h_length-.patch
ldconfig
__stack_chk_fail_local.c
......@@ -174,6 +180,12 @@ cc6a97327c6d16da0b8416f61266ef83 0020-fix-crash-when-signal-number-0-is-passed-
a9bd9d9659a359d5bd330aa42fc62d5e 0021-avoid-updating-caller-s-size-when-getdelim-fails-to-.patch
99f93be1cc75bc35ce51d6b221b9c7c1 0022-fix-overly-pessimistic-realloc-strategy-in-getdelim.patch
cde5cb6872b78efd8748e379b0865861 0023-add-missing-protocols-to-protoent-lookup-functions.patch
b08c3c22d1d15468db3bc8e064b1eb12 0024-fix-if_nametoindex-return-value-when-socket-open-fai.patch
0b2b71d302674fc4b2aa6c41209d653d 0025-handle-non-matching-address-family-entries-in-hosts-.patch
18113a9c07294d9011f8c9f8b88fe4d8 0026-math-fix-expf-NAN-and-exp2f-NAN-to-return-NAN-instea.patch
1d7ba3360de82b412df9c5a35de42375 0027-env-avoid-leaving-dangling-pointers-in-__env_map.patch
d85fdb4d80c8372d8e63cf4382e4012a 0028-fix-padding-string-formats-to-width-in-wide-printf-v.patch
366e32f17cbe18b4d4855eda6b4f82cb 1001-fix-gethostbyaddr_r-to-fill-struct-hostent.h_length-.patch
830d01f7821b978df770b06db3790921 ldconfig
0df687757221bbb0fc1aa67f1bd646f9 __stack_chk_fail_local.c
57ef2c63b9ec6a2041694ace97d4ffa2 getconf.c
......@@ -203,6 +215,12 @@ f8b10603a9e6ab53c7a6a90ac79eceee67aef2a3a2467a9c05b3eb6a0c661f7a 0019-fix-tsear
abbc746c46c96478c9ccc7ac3e61142e5dde63a00d80787d24e79802a4cd32b6 0021-avoid-updating-caller-s-size-when-getdelim-fails-to-.patch
3469865c391422dc56806c32b5ba373f2f0e67476235a69c172c8d9f866125cd 0022-fix-overly-pessimistic-realloc-strategy-in-getdelim.patch
b9c4ca23898d8f57c7ad26bd8214df2294b2ef06bf7a517dad3750ddd0581f75 0023-add-missing-protocols-to-protoent-lookup-functions.patch
52646b89d746100daf2608497bddbfb29f958aaea8eefbcb4e1b02babed743e6 0024-fix-if_nametoindex-return-value-when-socket-open-fai.patch
cdbf89a4f5baba60dc3d0a00d9d8dec7a9be32434b556aed93089a95f0f8724f 0025-handle-non-matching-address-family-entries-in-hosts-.patch
077dee932a5f3d72bf503b5593cde5c00a0d8c8b5593db10b55c26c2c3076e89 0026-math-fix-expf-NAN-and-exp2f-NAN-to-return-NAN-instea.patch
bb763a85b15f1dcdfb5b077ca387e81547fe548a49a2e303ff1715ed436557ba 0027-env-avoid-leaving-dangling-pointers-in-__env_map.patch
6037fa5aee8dba3d3b01ded5752d876954c23da3a53ed5a734f0816a2ef1d4bd 0028-fix-padding-string-formats-to-width-in-wide-printf-v.patch
4b54d17049582fa11b9e28406412ec0538af70476f9e2331e083e6ae37d938b9 1001-fix-gethostbyaddr_r-to-fill-struct-hostent.h_length-.patch
b4a2c06db38742e8c42c3c9838b285a7d8cdac6c091ff3df5ff9a15f1e41b9c7 ldconfig
299a7d75a09de3e2e11e7fb4acc3182e4a14e868093d2f30938fce9bfcff13da __stack_chk_fail_local.c
d87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c getconf.c
......@@ -232,6 +250,12 @@ dd14c638499a9364c64371f45183bc01b078594291da8b11a4a8bedf58cdb853502b8e871f52aae7
7b9618242ae75767a5eb7dc3ea83e2fb44ab073c1062cb1f7c3b2168f7185f442ff1438755e3e8bab8eee9406d08ba4bed0a39ec9c4b8fb7ff523424a020c920 0021-avoid-updating-caller-s-size-when-getdelim-fails-to-.patch
d166fabf4178c4f74113182a9294e1b864c78be1123bf0c5a59ec627017440369cabc31fe69c570df672a9eccfe891bddf5306fb9d638b0b69e5a2416af015ee 0022-fix-overly-pessimistic-realloc-strategy-in-getdelim.patch
feda1aa70f6bf70d00da1d633ad9b5a539abaa3638707a4c9ff624d2492086af381963c3ec021fc67c67c314967c66148fd6a8852ec1538936170f40c6f81525 0023-add-missing-protocols-to-protoent-lookup-functions.patch
5eb66a105b2214711b37926686100ca06cb648e523708e69496199ab8866073b131f186555249f622a5d61cb123ad87d14b59a2713255a102a42065d32c0d526 0024-fix-if_nametoindex-return-value-when-socket-open-fai.patch
ee46e61c2c77bed45827e3fd96645f5958f43f835d0e5284d86cdd29c5a30bab1b4b5ebc5604fcab3c476acd6cbf1000614903780f9e736800ef8e674195d73a 0025-handle-non-matching-address-family-entries-in-hosts-.patch
b8d9bcc784d0ee493a7bd2cabced7b4b2f1c7b7bd1627a118e9726c60b5cbb6f488afb15523efa643843ffe7a866f378cc8cc0b947acef942b89c4c5894f7572 0026-math-fix-expf-NAN-and-exp2f-NAN-to-return-NAN-instea.patch
463edc7db014cca90e069502aaa4910bcd1fe423670f8039e98c1bbb10987e4e39b38b125d269e8146a3c156a0c6d481bbcd5661e319624436fdcfbbf7299780 0027-env-avoid-leaving-dangling-pointers-in-__env_map.patch
fb30c3d1113e3cdaf575b37257b1184f2d5cc7cea0eb0ee94a71e861f9c72fe924de5f63826701584f68c9e1c9c4c1357a967ebe00f637312193e268f7a7cf94 0028-fix-padding-string-formats-to-width-in-wide-printf-v.patch
e3e0ebc19362e93ed1a278688e3acc082c23993daf0eb14ba011917ad076b2348bbe3fc9a939011884223f2dada3280b63fb7e7cb50373bebff0cf857899acaa 1001-fix-gethostbyaddr_r-to-fill-struct-hostent.h_length-.patch
8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c
0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d getconf.c
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment