From a70633c31fb0525b9411c259a394f67c1f489ab1 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 14 Dec 2009 05:08:20 +0100 Subject: [PATCH] Handle cases when provided DNS server has no interface --- plugins/dnsproxy.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/dnsproxy.c b/plugins/dnsproxy.c index a84707a..40426c6 100644 --- a/plugins/dnsproxy.c +++ b/plugins/dnsproxy.c @@ -226,12 +226,15 @@ static struct server_data *create_server(const char *interface, return NULL; } - if (setsockopt(sk, SOL_SOCKET, SO_BINDTODEVICE, + if (interface != NULL) { + if (setsockopt(sk, SOL_SOCKET, SO_BINDTODEVICE, interface, strlen(interface) + 1) < 0) { - connman_error("Failed to bind server %s to interface %s", + connman_error("Failed to bind server %s " + "to interface %s", server, interface); - close(sk); - return NULL; + close(sk); + return NULL; + } } memset(&sin, 0, sizeof(sin)); @@ -263,7 +266,7 @@ static struct server_data *create_server(const char *interface, g_io_channel_set_close_on_unref(data->channel, TRUE); data->watch = g_io_add_watch(data->channel, G_IO_IN, - server_event, data); + server_event, data); data->interface = g_strdup(interface); data->domain = g_strdup(domain); -- 2.7.4