Do not access the DNS request buffer if it's NULL
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 24 Sep 2010 18:42:31 +0000 (20:42 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 24 Sep 2010 18:42:31 +0000 (20:42 +0200)
plugins/dnsproxy.c

index 63c88b9..ac18490 100644 (file)
@@ -482,11 +482,14 @@ static gboolean tcp_server_event(GIOChannel *channel, GIOCondition condition,
 
                for (list = request_list; list; list = list->next) {
                        struct request_data *req = list->data;
-                       struct domain_hdr *hdr = (void *) (req->request + 2);
+                       struct domain_hdr *hdr;
 
                        if (req->protocol == IPPROTO_UDP)
                                continue;
 
+                       if (req->request == NULL)
+                               continue;
+
                        /*
                         * If we're not waiting for any further response
                         * from another name server, then we send an error
@@ -495,6 +498,7 @@ static gboolean tcp_server_event(GIOChannel *channel, GIOCondition condition,
                        if (req->numserv && --(req->numserv))
                                continue;
 
+                       hdr = (void *) (req->request + 2);
                        hdr->id = req->srcid;
                        send_response(req->client_sk, req->request,
                                        req->request_len, NULL, 0, IPPROTO_TCP);