[banshee] Daap: Fix crash while resolving the address of a DAAP service



commit 8e675f133a37eb96aef39130e6cb174239eb63d5
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Sun Oct 23 13:06:42 2011 +0200

    Daap: Fix crash while resolving the address of a DAAP service
    
    Resolving the hostname of an IPv6 service might fail, so we need to
    catch the resulting SocketException.

 src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs b/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs
index ccb0107..75a908e 100644
--- a/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs
+++ b/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs
@@ -166,11 +166,14 @@ namespace Daap {
                 // This is the first address we've resolved, however, it's an IPv6 address.
                 // Try and resolve the hostname in hope that it'll end up as an IPv4 address - it doesn't
                 // really matter if it still ends up with an IPv6 address, we're not risking anything.
-
-                foreach (IPAddress addr in Dns.GetHostEntry (args.Service.HostEntry.HostName).AddressList) {
-                    if (addr.AddressFamily == AddressFamily.InterNetwork) {
-                        address = addr;
+                try {
+                    foreach (IPAddress addr in Dns.GetHostEntry (args.Service.HostEntry.HostName).AddressList) {
+                        if (addr.AddressFamily == AddressFamily.InterNetwork) {
+                            address = addr;
+                        }
                     }
+                } catch (SocketException) {
+                    Log.WarningFormat ("Unable to resolve IPv6 host {0}", args.Service.HostEntry.HostName);
                 }
             }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]