summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornpmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56>2007-11-20 23:43:39 +0000
committernpmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56>2007-11-20 23:43:39 +0000
commite01d858ead6d00fa9fe2bb876ac92e0753009310 (patch)
treeb1c451d9906e976bbe65ee7ad04511c29200ec49
parent50811783ed37bca5392f96b621e1942d46c96983 (diff)
downloadlibproxy-git-e01d858ead6d00fa9fe2bb876ac92e0753009310.tar.gz
make dns WPAD a bit more robust
-rw-r--r--src/lib/dns.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/dns.c b/src/lib/dns.c
index ddf55a6..9fb5d44 100644
--- a/src/lib/dns.c
+++ b/src/lib/dns.c
@@ -96,6 +96,15 @@ get_domain_name()
static pxURL **
get_urls(const char *domain)
{
+ pxURL **urls;
+
+ if (!domain)
+ {
+ urls = px_malloc0(sizeof(pxURL *) * 2);
+ urls[0] = px_url_new("http://wpad/wpad.dat");
+ return urls;
+ }
+
// Split up the domain
char **domainv = px_strsplit(domain, ".");
if (!domainv) return NULL;
@@ -106,7 +115,7 @@ get_urls(const char *domain)
count++;
// Allocate our URL array
- pxURL **urls = px_malloc0(sizeof(pxURL *) * (count + 2));
+ urls = px_malloc0(sizeof(pxURL *) * (count + 2));
// Create the URLs
urls[0] = px_url_new("http://wpad/wpad.dat");
@@ -160,6 +169,8 @@ px_dns_new_full(const char *domain)
pxPAC *
px_dns_next(pxDNS *self)
{
+ if (!self) return NULL;
+
if (!self->urls) {
char *domain;
@@ -171,7 +182,6 @@ px_dns_next(pxDNS *self)
domain = px_strdup(self->domain);
else
domain = get_domain_name();
- if (!domain) return NULL;
// Get the URLs
self->urls = get_urls(domain);