VirtualBox

Changeset 53366 in vbox for trunk


Ignore:
Timestamp:
Nov 21, 2014 2:09:36 AM (10 years ago)
Author:
vboxsync
Message:

NAT/Net: Fix size calculations when allocating a pong, don't
over-allocate struct padding.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/pxping_win.c

    r51974 r53366  
    193193
    194194    bufsize = sizeof(ICMP_ECHO_REPLY) + p->tot_len;
    195     pong = (struct pong4 *)malloc(sizeof(*pong) - sizeof(pong->buf) + bufsize);
     195    pong = (struct pong4 *)malloc(RT_OFFSETOF(struct pong4, buf) + bufsize);
    196196    if (RT_UNLIKELY(pong == NULL)) {
    197197        goto out;
     
    470470
    471471    bufsize = sizeof(ICMPV6_ECHO_REPLY) + p->tot_len;
    472     pong = (struct pong6 *)malloc(sizeof(*pong) - sizeof(pong->buf) + bufsize);
     472    pong = (struct pong6 *)malloc(RT_OFFSETOF(struct pong6, buf) + bufsize);
    473473    if (RT_UNLIKELY(pong == NULL)) {
    474474        goto out;
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