VirtualBox

Changeset 53380 in vbox for trunk


Ignore:
Timestamp:
Nov 24, 2014 2:28:53 AM (10 years ago)
Author:
vboxsync
Message:

NAT: allocate extra space for ICMP API internal use if reqest size is too small

File:
1 edited

Legend:

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

    r53360 r53380  
    115115{
    116116    struct ip *ip = mtod(m, struct ip *);
    117     int icmplen = ip->ip_len - hlen;
     117    size_t reqsize;
    118118    uint8_t ttl;
    119119    size_t bufsize;
     
    122122    IP_OPTION_INFORMATION opts;
    123123    void *reqdata;
    124     size_t reqsize;
    125124    int status;
    126125
     
    129128    --ttl;
    130129
    131     bufsize = sizeof(ICMP_ECHO_REPLY) + icmplen;
     130    reqsize = ip->ip_len - hlen - sizeof(struct icmp_echo);
     131
     132    bufsize = sizeof(ICMP_ECHO_REPLY);
     133    if (reqsize < sizeof(IO_STATUS_BLOCK) + sizeof(struct icmp_echo))
     134        bufsize += sizeof(IO_STATUS_BLOCK) + sizeof(struct icmp_echo);
     135    else
     136        bufsize += reqsize;
     137    bufsize += 16; /* whatever that is; empirically at least XP needs it */
     138    LogRel(("NAT: ping size=%d bufsize=%d\n", (int)reqsize, (int)bufsize));
     139
    132140    pong = RTMemAlloc(RT_OFFSETOF(struct pong, buf) + bufsize);
    133141    if (RT_UNLIKELY(pong == NULL))
     
    140148    AssertReturnVoid(pong->reqicmph.icmp_type == ICMP_ECHO);
    141149
    142     reqsize = icmplen - sizeof(struct icmp_echo); /* just the payload */
    143150    if (m->m_next == NULL)
    144151    {
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