diff options
author | Timo Teräs <timo.teras@iki.fi> | 2016-03-02 14:07:09 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2016-03-02 14:11:26 +0200 |
commit | 0f79ca454f3f7d7ae00997cb41fbb4ec518f89a7 (patch) | |
tree | 92804430c6ee32d3628abbcc1724a227e53701bd /main/musl/0001-handle-non-matching-address-family-entries-in-hosts-.patch | |
parent | 46e900d67115a68411ae0405e945258eaad3141c (diff) | |
download | aports-0f79ca454f3f7d7ae00997cb41fbb4ec518f89a7.tar.bz2 aports-0f79ca454f3f7d7ae00997cb41fbb4ec518f89a7.tar.xz |
main/musl: cherry-pick bre fixes from upstream git
Diffstat (limited to 'main/musl/0001-handle-non-matching-address-family-entries-in-hosts-.patch')
-rw-r--r-- | main/musl/0001-handle-non-matching-address-family-entries-in-hosts-.patch | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/main/musl/0001-handle-non-matching-address-family-entries-in-hosts-.patch b/main/musl/0001-handle-non-matching-address-family-entries-in-hosts-.patch new file mode 100644 index 0000000000..927106d574 --- /dev/null +++ b/main/musl/0001-handle-non-matching-address-family-entries-in-hosts-.patch @@ -0,0 +1,62 @@ +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.2 + |