gweb: numeric session address was not resolved properly.
authorJukka Rissanen <jukka.rissanen@nokia.com>
Tue, 5 Apr 2011 10:57:41 +0000 (13:57 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 11 Apr 2011 19:37:58 +0000 (21:37 +0200)
Reported by: Sebastien Bianti <sebastien.bianti@linux.intel.com>

gweb/gweb.c

index 75e64d9..9c9fcd1 100644 (file)
@@ -1148,9 +1148,30 @@ static guint do_request(GWeb *web, const char *url,
                        return 0;
                }
        } else {
+               struct addrinfo hints;
+               char *port;
+               int ret;
+
                if (session->address == NULL)
                        session->address = g_strdup(session->host);
 
+               memset(&hints, 0, sizeof(struct addrinfo));
+               hints.ai_flags = AI_NUMERICHOST;
+
+               if (session->addr != NULL) {
+                       freeaddrinfo(session->addr);
+                       session->addr = NULL;
+               }
+
+               port = g_strdup_printf("%u", session->port);
+               ret = getaddrinfo(session->address, port, &hints,
+                                                       &session->addr);
+               g_free(port);
+               if (ret != 0 || session->addr == NULL) {
+                       free_session(session);
+                       return 0;
+               }
+
                if (create_transport(session) < 0) {
                        free_session(session);
                        return 0;