summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2013-04-01 20:41:12 +0000
committereric <eric@openbsd.org>2013-04-01 20:41:12 +0000
commitddc6d4c56b4113fe9bc82a2de4b927c0cc76e74e (patch)
tree65cab7b2ccacb669fb9a77421ffad18aee22a030 /lib/libc
parentproperly check for domain name truncation at various places and fail (diff)
downloadwireguard-openbsd-ddc6d4c56b4113fe9bc82a2de4b927c0cc76e74e.tar.xz
wireguard-openbsd-ddc6d4c56b4113fe9bc82a2de4b927c0cc76e74e.zip
If more than one lookup line is found in resolv.conf, the latest one
takes precedence. Simplify code while there. suggested by deraadt@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/asr/asr.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c
index 6a98f17c4ef..6d618eb774f 100644
--- a/lib/libc/asr/asr.c
+++ b/lib/libc/asr/asr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr.c,v 1.20 2013/04/01 20:22:27 eric Exp $ */
+/* $OpenBSD: asr.c,v 1.21 2013/04/01 20:41:12 eric Exp $ */
/*
* Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org>
*
@@ -609,28 +609,19 @@ pass0(char **tok, int n, struct asr_ctx *ac)
ac->ac_domain = strdup(tok[1]);
} else if (!strcmp(tok[0], "lookup")) {
- /* ignore the line if we already set lookup */
- if (ac->ac_dbcount != 0)
- return;
- if (n - 1 > ASR_MAXDB)
- return;
/* ensure that each lookup is only given once */
for (i = 1; i < n; i++)
for (j = i + 1; j < n; j++)
if (!strcmp(tok[i], tok[j]))
return;
- for (i = 1; i < n; i++, ac->ac_dbcount++) {
- if (!strcmp(tok[i], "yp")) {
- ac->ac_db[i-1] = ASR_DB_YP;
- } else if (!strcmp(tok[i], "bind")) {
- ac->ac_db[i-1] = ASR_DB_DNS;
- } else if (!strcmp(tok[i], "file")) {
- ac->ac_db[i-1] = ASR_DB_FILE;
- } else {
- /* ignore the line */
- ac->ac_dbcount = 0;
- return;
- }
+ ac->ac_dbcount = 0;
+ for (i = 1; i < n && ac->ac_dbcount < ASR_MAXDB; i++) {
+ if (!strcmp(tok[i], "yp"))
+ ac->ac_db[ac->ac_dbcount++] = ASR_DB_YP;
+ else if (!strcmp(tok[i], "bind"))
+ ac->ac_db[ac->ac_dbcount++] = ASR_DB_DNS;
+ else if (!strcmp(tok[i], "file"))
+ ac->ac_db[ac->ac_dbcount++] = ASR_DB_FILE;
}
} else if (!strcmp(tok[0], "search")) {
/* resolv.conf says the last line wins */