dns: implement tcp fallback in __res_msend query core
[musl] / src / network / resolvconf.c
index 0743a88..ceabf08 100644 (file)
@@ -3,6 +3,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <string.h>
+#include <stdlib.h>
 #include <netinet/in.h>
 
 int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
@@ -10,7 +11,7 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
        char line[256];
        unsigned char _buf[256];
        FILE *f, _f;
-       int nns;
+       int nns = 0;
 
        conf->ndots = 1;
        conf->timeout = 5;
@@ -45,8 +46,8 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
                                if (z != p) conf->ndots = x > 15 ? 15 : x;
                        }
                        p = strstr(line, "attempts:");
-                       if (p && isdigit(p[6])) {
-                               p += 6;
+                       if (p && isdigit(p[9])) {
+                               p += 9;
                                unsigned long x = strtoul(p, &z, 10);
                                if (z != p) conf->attempts = x > 10 ? 10 : x;
                        }
@@ -69,7 +70,7 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
                }
 
                if (!search) continue;
-               if (strncmp(line, "domain", 6) || strncmp(line, "search", 6)
+               if ((strncmp(line, "domain", 6) && strncmp(line, "search", 6))
                    || !isspace(line[6]))
                        continue;
                for (p=line+7; isspace(*p); p++);