gweb: Add port string to getaddrinfo
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 1 Apr 2011 14:59:44 +0000 (16:59 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 1 Apr 2011 14:59:44 +0000 (16:59 +0200)
Without doing so, the socket address returned will have its port field
uninitialized.

Fixes BMC#14753
Fixes BMC#15026

gweb/gweb.c

index 1bb1c70..75e64d9 100644 (file)
@@ -1049,6 +1049,7 @@ static void resolv_result(GResolvResultStatus status,
 {
        struct web_session *session = user_data;
        struct addrinfo hints;
+       char *port;
        int ret;
 
        if (results == NULL || results[0] == NULL) {
@@ -1066,7 +1067,9 @@ static void resolv_result(GResolvResultStatus status,
                session->addr = NULL;
        }
 
-       ret = getaddrinfo(results[0], NULL, &hints, &session->addr);
+       port = g_strdup_printf("%u", session->port);
+       ret = getaddrinfo(results[0], port, &hints, &session->addr);
+       g_free(port);
        if (ret != 0 || session->addr == NULL) {
                call_result_func(session, 400);
                return;