VirtualBox

Changeset 45261 in vbox for trunk/src


Ignore:
Timestamp:
Mar 31, 2013 2:03:24 AM (12 years ago)
Author:
vboxsync
Message:

NAT: dnsproxy crush fix attempt.

on return from timeout operation, references to timeout should be cleared.

Location:
trunk/src/VBox/Devices/Network/slirp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/dnsproxy/dnsproxy.c

    r40423 r45261  
    11/* $Id$ */
     2
     3/*
     4 * Copyright (C) 2009-2013 Oracle Corporation
     5 *
     6 * This file is part of VirtualBox Open Source Edition (OSE), as
     7 * available from http://www.virtualbox.org. This file is free software;
     8 * you can redistribute it and/or modify it under the terms of the GNU
     9 * General Public License (GPL) as published by the Free Software
     10 * Foundation, in version 2 as it comes in the "COPYING" file of the
     11 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
     12 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
     13 *
     14 * The contents of this file may alternatively be used under the terms
     15 * of the Common Development and Distribution License Version 1.0
     16 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
     17 * VirtualBox OSE distribution, in which case the provisions of the
     18 * CDDL are applicable instead of those of the GPL.
     19 *
     20 * You may elect to license modified versions of this file under the
     21 * terms and conditions of either the GPL or the CDDL or both.
     22 */
     23
    224/*
    325 * Copyright (c) 2003,2004,2005 Armin Wolfermann
     
    105127    struct request *req = (struct request *)arg;
    106128    struct dns_entry *de;
     129    /* be paranoid */
     130    AssertPtrReturnVoid(arg);
    107131    de = TAILQ_PREV(req->dns_server, dns_list_head, de_list);
    108132    /* here we should check if we reached the end of the DNS server list */
     
    112136        RTMemFree(req);
    113137        ++removed_queries;
     138        /* the rest of clean up at the end of the method. */
    114139    }
    115140    else
    116141    {
     142        /* Note: so will be deleted after we create new one (so1)
     143         * to make attempt on the next server.
     144         */
    117145        struct ip *ip;
    118146        struct udphdr *udp;
     
    121149        struct mbuf *m = NULL;
    122150        char *data;
     151
    123152        if (so1 == NULL)
    124153        {
    125154            LogRel(("NAT: can't create DNS socket\n"));
    126             return;
    127         }
     155            goto socket_clean_up;
     156        }
     157
    128158        if(udp_attach(pData, so1) == -1)
    129159        {
    130160            LogRel(("NAT: can't attach udp socket\n"));
    131161            sofree(pData, so1);
    132             return;
    133         }
     162            goto socket_clean_up;
     163        }
     164
    134165        m = slirpDnsMbufAlloc(pData);
    135166        if (m == NULL)
     
    137168            LogRel(("NAT: Can't allocate mbuf\n"));
    138169            udp_detach(pData, so1);
    139             return;
    140         }
     170            goto socket_clean_up;
     171        }
     172
    141173        /* mbuf initialization */
    142174        m->m_data += if_maxlinkhdr;
     175
    143176        ip = mtod(m, struct ip *);
    144177        udp = (struct udphdr *)&ip[1]; /* ip attributes */
    145178        data = (char *)&udp[1];
    146179        iphlen = sizeof(struct ip);
     180
    147181        m->m_len += sizeof(struct ip);
    148182        m->m_len += sizeof(struct udphdr);
    149183        m->m_len += req->nbyte;
     184
    150185        ip->ip_src.s_addr = so->so_laddr.s_addr;
    151186        ip->ip_dst.s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_DNS);
     
    158193        so1->so_faddr = so->so_faddr;
    159194        so1->so_fport = so->so_fport;
     195
    160196        req->dns_server = de;
    161197        so1->so_timeout_arg = req;
    162198        so1->so_timeout = timeout;
     199
    163200        dnsproxy_query(pData, so1, m, iphlen);
    164201    }
     202 
     203 socket_clean_up:   
     204    /* This socket (so) will be detached, so we need to remove timeout(&_arg) references
     205     * before leave
     206     */
     207    so->so_timeout = NULL;
     208    so->so_timeout_arg = NULL;
     209    return;
     210
    165211}
    166212#endif /* VBOX */
  • trunk/src/VBox/Devices/Network/slirp/queue.h

    r28800 r45261  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r43752 r45261  
    196196     */
    197197    Assert(!sototcpcb(so));
     198    /* udp checks */
     199    Assert(!so->so_timeout);
     200    Assert(!so->so_timeout_arg);
    198201    if (so == tcp_last_so)
    199202        tcp_last_so = &tcb;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette