Ticket #1071: ieee80211_input_crash_fix.3.diff

File ieee80211_input_crash_fix.3.diff, 1.3 kB (added by rozteck@interia.pl, 5 years ago)

This patch adds some NULL pointer checking. Signed-off-by: Tomasz Rostanski <rozteck@interia.pl>

  • net80211/ieee80211_input.c

    old new  
    222222        struct sk_buff *skb, int rssi, u_int32_t rstamp) 
    223223{ 
    224224#define HAS_SEQ(type)   ((type & 0x4) == 0) 
    225         struct ieee80211vap *vap = ni->ni_vap; 
    226         struct ieee80211com *ic = vap->iv_ic
     225        struct ieee80211vap *vap = NULL;  
     226        struct ieee80211com *ic = NULL
    227227        struct ieee80211_node *ni_wds = NULL; 
    228         struct net_device *dev = vap->iv_dev
     228        struct net_device *dev = NULL
    229229        struct ieee80211_frame *wh; 
    230230        struct ieee80211_key *key; 
    231231        struct ether_header *eh; 
     
    236236        u_int8_t dir, type, subtype; 
    237237        u_int8_t *bssid; 
    238238        u_int16_t rxseq; 
     239         
     240        KASSERT(ni != NULL, ("null node")); 
     241         
     242        type = -1;                      /* undefined */ 
    239243 
    240         KASSERT(ni != NULL, ("null node")); 
     244        vap = ni->ni_vap; 
     245        if (vap == NULL) goto out; 
     246         
     247        ic = vap->iv_ic; 
     248        if (ic == NULL) goto out; 
     249         
     250        dev = vap->iv_dev; 
     251        if (dev == NULL) goto out; 
     252 
    241253        ni->ni_inact = ni->ni_inact_reload; 
    242254 
    243255        KASSERT(skb->len >= sizeof(struct ieee80211_frame_min), 
    244256                ("frame length too short: %u", skb->len)); 
    245257 
    246258        /* XXX adjust device in sk_buff? */ 
    247  
    248         type = -1;                      /* undefined */ 
     259         
    249260        /* 
    250261         * In monitor mode, send everything directly to bpf. 
    251262         * Also do not process frames w/o i_addr2 any further.