diff options
| author | 2009-06-04 21:38:29 +0000 | |
|---|---|---|
| committer | 2009-06-04 21:38:29 +0000 | |
| commit | dae2c33ca827ca150fd0d318200ccf3df7215806 (patch) | |
| tree | 37931b16ebd6f509275393f8ab8b138b2b39080d /lib/libc/net/res_init.c | |
| parent | Fix fallback from struct disklabel changes. (diff) | |
| download | wireguard-openbsd-dae2c33ca827ca150fd0d318200ccf3df7215806.tar.xz wireguard-openbsd-dae2c33ca827ca150fd0d318200ccf3df7215806.zip | |
simplify the 'family' option parser and make it more evident what we're
now doing.
ok deraadt@
Diffstat (limited to 'lib/libc/net/res_init.c')
| -rw-r--r-- | lib/libc/net/res_init.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/libc/net/res_init.c b/lib/libc/net/res_init.c index 5cb597dad80..aafa9bbc87e 100644 --- a/lib/libc/net/res_init.c +++ b/lib/libc/net/res_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: res_init.c,v 1.38 2009/06/04 18:06:35 pyr Exp $ */ +/* $OpenBSD: res_init.c,v 1.39 2009/06/04 21:38:29 pyr Exp $ */ /* * ++Copyright++ 1985, 1989, 1993 @@ -281,6 +281,9 @@ _res_init(int usercall) (line[sizeof(name) - 1] == ' ' || \ line[sizeof(name) - 1] == '\t')) + /* initialize family lookup preference: inet4 first */ + _resp->family[0] = AF_INET; + _resp->family[1] = AF_INET6; if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { strlcpy(_resp->lookups, "bf", sizeof _resp->lookups); @@ -312,6 +315,9 @@ _res_init(int usercall) strlen("inet4"))) { _resp->family[findex] = AF_INET; cp += strlen("inet4"); + } else { + _resp->family[0] = -1; + break; } if (*cp != ' ' && *cp != '\t' && *cp != '\0') { _resp->family[findex] = -1; @@ -321,6 +327,11 @@ _res_init(int usercall) cp += strspn(cp, " \t"); } + if (_resp->family[0] == -1) { + /* line contains errors, reset to defaults */ + _resp->family[0] = AF_INET; + _resp->family[1] = AF_INET6; + } if (_resp->family[0] == _resp->family[1]) _resp->family[1] = -1; } |
