diff options
Diffstat (limited to 'src/lib/libc/net/res_init.c')
| -rw-r--r-- | src/lib/libc/net/res_init.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/lib/libc/net/res_init.c b/src/lib/libc/net/res_init.c index 42d3b3ca1e..5cb597dad8 100644 --- a/src/lib/libc/net/res_init.c +++ b/src/lib/libc/net/res_init.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: res_init.c,v 1.37 2008/08/15 14:57:20 djm Exp $ */ | 1 | /* $OpenBSD: res_init.c,v 1.38 2009/06/04 18:06:35 pyr Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * ++Copyright++ 1985, 1989, 1993 | 4 | * ++Copyright++ 1985, 1989, 1993 |
| @@ -165,6 +165,7 @@ _res_init(int usercall) | |||
| 165 | FILE *fp; | 165 | FILE *fp; |
| 166 | char *cp, **pp; | 166 | char *cp, **pp; |
| 167 | int n; | 167 | int n; |
| 168 | int findex; | ||
| 168 | char buf[BUFSIZ]; | 169 | char buf[BUFSIZ]; |
| 169 | int nserv = 0; /* number of nameserver records read from file */ | 170 | int nserv = 0; /* number of nameserver records read from file */ |
| 170 | int haveenv = 0; | 171 | int haveenv = 0; |
| @@ -296,6 +297,33 @@ _res_init(int usercall) | |||
| 296 | *cp = '\0'; | 297 | *cp = '\0'; |
| 297 | if (buf[0] == '\0') | 298 | if (buf[0] == '\0') |
| 298 | continue; | 299 | continue; |
| 300 | /* set family lookup order */ | ||
| 301 | if (MATCH(buf, "family")) { | ||
| 302 | cp = buf + sizeof("family") - 1; | ||
| 303 | cp += strspn(cp, " \t"); | ||
| 304 | cp[strcspn(cp, "\n")] = '\0'; | ||
| 305 | findex = 0; | ||
| 306 | _resp->family[0] = _resp->family[1] = -1; | ||
| 307 | while (*cp != '\0' && findex < 2) { | ||
| 308 | if (!strncmp(cp, "inet6", strlen("inet6"))) { | ||
| 309 | _resp->family[findex] = AF_INET6; | ||
| 310 | cp += strlen("inet6"); | ||
| 311 | } else if (!strncmp(cp, "inet4", | ||
| 312 | strlen("inet4"))) { | ||
| 313 | _resp->family[findex] = AF_INET; | ||
| 314 | cp += strlen("inet4"); | ||
| 315 | } | ||
| 316 | if (*cp != ' ' && *cp != '\t' && *cp != '\0') { | ||
| 317 | _resp->family[findex] = -1; | ||
| 318 | break; | ||
| 319 | } | ||
| 320 | findex++; | ||
| 321 | cp += strspn(cp, " \t"); | ||
| 322 | } | ||
| 323 | |||
| 324 | if (_resp->family[0] == _resp->family[1]) | ||
| 325 | _resp->family[1] = -1; | ||
| 326 | } | ||
| 299 | /* read default domain name */ | 327 | /* read default domain name */ |
| 300 | if (MATCH(buf, "domain")) { | 328 | if (MATCH(buf, "domain")) { |
| 301 | if (haveenv) /* skip if have from environ */ | 329 | if (haveenv) /* skip if have from environ */ |
