From: William Pitcock <nenolod@dereferenced.org>
To: musl@lists.openwall.com
Cc: William Pitcock <nenolod@dereferenced.org>
Subject: [PATCH] resolv.conf parser: concatenate multiple search domain lines
Date: Fri, 30 Mar 2018 10:51:59 +0000 [thread overview]
Message-ID: <20180330105159.19583-1-nenolod@dereferenced.org> (raw)
Programs such as Docker and Kubernetes write multiple domain search lines, such as
search serious-business.big-data.prod.foo.com
search big-data.prod.foo.com
search prod.foo.com
instead of
search serious-business.big-data.prod.foo.com big-data.prod.foo.com prod.foo.com
Accordingly, we concatenate the namelist together so that the search path is
not truncated.
(Sorry, not sorry, for ruining the "omg Alpine sucks at DNS" talk at Kubecon)
---
src/network/lookup_name.c | 2 +-
src/network/resolvconf.c | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/network/lookup_name.c b/src/network/lookup_name.c
index 209c20f0..c83c11c5 100644
--- a/src/network/lookup_name.c
+++ b/src/network/lookup_name.c
@@ -172,7 +172,7 @@ static int name_from_dns(struct address buf[static MAXADDRS], char canon[static
static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
{
- char search[256];
+ char search[2048];
struct resolvconf conf;
size_t l, dots;
char *p, *z;
diff --git a/src/network/resolvconf.c b/src/network/resolvconf.c
index 4c3e4c4b..72ed4082 100644
--- a/src/network/resolvconf.c
+++ b/src/network/resolvconf.c
@@ -9,6 +9,7 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
{
char line[256];
unsigned char _buf[256];
+ char *search_base = search;
FILE *f, _f;
int nns = 0;
@@ -74,9 +75,13 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
continue;
for (p=line+7; isspace(*p); p++);
size_t l = strlen(p);
+ ptrdiff_t m = search - search_base;
/* This can never happen anyway with chosen buffer sizes. */
- if (l >= search_sz) continue;
+ if (l + m >= search_sz) continue;
memcpy(search, p, l+1);
+ /* We concatenate the search list as domain1 domain2\0 */
+ search += l;
+ *search++ = ' ';
}
__fclose_ca(f);
--
2.16.2
next reply other threads:[~2018-03-30 10:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-30 10:51 William Pitcock [this message]
2018-03-30 12:27 ` Quentin Rameau
2018-03-30 13:21 ` Rich Felker
2018-03-30 18:54 ` William Pitcock
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180330105159.19583-1-nenolod@dereferenced.org \
--to=nenolod@dereferenced.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).