VirtualBox

Changeset 87126 in vbox for trunk/src


Ignore:
Timestamp:
Dec 25, 2020 2:51:44 AM (4 years ago)
Author:
vboxsync
Message:

slirp: arp_input - more checks on incoming packets.

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

Legend:

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

    r82968 r87126  
    12541254{
    12551255    unsigned short  ar_hrd;             /* format of hardware address   */
     1256#define ARPHRD_ETHER    1               /* ethernet hardware format     */
    12561257    unsigned short  ar_pro;             /* format of protocol address   */
    12571258    unsigned char   ar_hln;             /* length of hardware address   */
    12581259    unsigned char   ar_pln;             /* length of protocol address   */
    12591260    unsigned short  ar_op;              /* ARP opcode (command)         */
     1261#define ARPOP_REQUEST   1               /* ARP request                  */
     1262#define ARPOP_REPLY     2               /* ARP reply                    */
    12601263
    12611264    /*
     
    13231326    struct ethhdr *pEtherHeader;
    13241327    struct arphdr *pARPHeader;
     1328    int ar_op;
    13251329    uint32_t ip4TargetAddress;
    13261330
    1327     int ar_op;
     1331    /* drivers never return runt packets, so this should never happen */
     1332    if (RT_UNLIKELY((size_t)m->m_len
     1333                    < sizeof(struct ethhdr) + sizeof(struct arphdr)))
     1334        goto done;
     1335
    13281336    pEtherHeader = mtod(m, struct ethhdr *);
    13291337    pARPHeader = (struct arphdr *)&pEtherHeader[1];
     1338
     1339    if (RT_UNLIKELY(   pARPHeader->ar_hrd != RT_H2N_U16_C(ARPHRD_ETHER)
     1340                    || pARPHeader->ar_pro != RT_H2N_U16_C(ETH_P_IP)
     1341                    || pARPHeader->ar_hln != ETH_ALEN
     1342                    || pARPHeader->ar_pln != sizeof(RTNETADDRIPV4)))
     1343        goto done;
    13301344
    13311345    ar_op = RT_N2H_U16(pARPHeader->ar_op);
     
    13651379    }
    13661380
     1381  done:
    13671382    m_freem(pData, m);
    13681383}
  • trunk/src/VBox/Devices/Network/slirp/slirp.h

    r85195 r87126  
    390390# define ETH_HLEN        14
    391391
    392 # define ARPOP_REQUEST   1               /* ARP request                  */
    393 # define ARPOP_REPLY     2               /* ARP reply                    */
    394 
    395392struct ethhdr
    396393{
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