VirtualBox

Ignore:
Timestamp:
Apr 12, 2017 8:48:26 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114530
Message:

Devices/Network/slirp: bugref:8736: additional sanity check

File:
1 edited

Legend:

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

    r65455 r66522  
    9595    int hlen = 0;
    9696    int mlen = 0;
     97    int iplen = 0;
    9798
    9899    STAM_PROFILE_START(&pData->StatIP_input, a);
     
    103104
    104105    ipstat.ips_total++;
    105     {
    106         int rc;
    107         if (!(m->m_flags & M_SKIP_FIREWALL))
    108         {
    109             STAM_PROFILE_START(&pData->StatALIAS_input, b);
    110             rc = LibAliasIn(pData->proxy_alias, mtod(m, char *), m_length(m, NULL));
    111             STAM_PROFILE_STOP(&pData->StatALIAS_input, b);
    112             Log2(("NAT: LibAlias return %d\n", rc));
    113         }
    114         else
    115             m->m_flags &= ~M_SKIP_FIREWALL;
    116 
    117         /*
    118          * XXX: TODO: this is most likely a leftover spooky action at
    119          * a distance from alias_dns.c host resolver code and can be
    120          * g/c'ed.
    121          */
    122         if (m->m_len != RT_N2H_U16(ip->ip_len))
    123             m->m_len = RT_N2H_U16(ip->ip_len);
    124     }
    125106
    126107    mlen = m->m_len;
     
    158139    }
    159140
    160     /*
    161      * Convert fields to host representation.
    162      */
    163     NTOHS(ip->ip_len);
    164     if (ip->ip_len < hlen)
     141    iplen = RT_N2H_U16(ip->ip_len);
     142    if (iplen < hlen)
    165143    {
    166144        ipstat.ips_badlen++;
    167145        goto bad_free_m;
    168146    }
    169 
    170     NTOHS(ip->ip_id);
    171     NTOHS(ip->ip_off);
    172147
    173148    /*
     
    177152     * Drop packet if shorter than we expect.
    178153     */
    179     if (mlen < ip->ip_len)
     154    if (mlen < iplen)
    180155    {
    181156        ipstat.ips_tooshort++;
     
    184159
    185160    /* Should drop packet if mbuf too long? hmmm... */
    186     if (mlen > ip->ip_len)
    187         m_adj(m, ip->ip_len - mlen);
     161    if (mlen > iplen)
     162    {
     163        m_adj(m, iplen - mlen);
     164        mlen = m->m_len;
     165    }
    188166
    189167    /* source must be unicast */
     
    208186        if (ip->ip_ttl <= 1)
    209187        {
     188            /* icmp_error expects these in host order */
     189            NTOHS(ip->ip_len);
     190            NTOHS(ip->ip_id);
     191            NTOHS(ip->ip_off);
     192
    210193            icmp_error(pData, m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, "ttl");
    211194            goto no_free_m;
     
    227210    }
    228211
     212    /* run it through libalias */
     213    {
     214        int rc;
     215        if (!(m->m_flags & M_SKIP_FIREWALL))
     216        {
     217            STAM_PROFILE_START(&pData->StatALIAS_input, b);
     218            rc = LibAliasIn(pData->proxy_alias, mtod(m, char *), mlen);
     219            STAM_PROFILE_STOP(&pData->StatALIAS_input, b);
     220            Log2(("NAT: LibAlias return %d\n", rc));
     221        }
     222        else
     223            m->m_flags &= ~M_SKIP_FIREWALL;
     224
     225#if 0 /* disabled: no module we use does it in this direction */
     226        /*
     227         * XXX: spooky action at a distance - libalias may modify the
     228         * packet and will update ip_len to reflect the new length.
     229         */
     230        if (iplen != RT_N2H_U16(ip->ip_len))
     231        {
     232            iplen = RT_N2H_U16(ip->ip_len);
     233            m->m_len = iplen;
     234            mlen = m->m_len;
     235        }
     236#endif
     237    }
     238
     239    /*
     240     * Convert fields to host representation.
     241     */
     242    NTOHS(ip->ip_len);
     243    NTOHS(ip->ip_id);
     244    NTOHS(ip->ip_off);
    229245
    230246    /*
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