]> The Tcpdump Group git mirrors - libpcap/commitdiff
support pEnd check for strtoul
authorjingleyang <[email protected]>
Mon, 24 Dec 2018 03:45:57 +0000 (11:45 +0800)
committerjingleyang <[email protected]>
Mon, 24 Dec 2018 03:45:57 +0000 (11:45 +0800)
pcap-dpdk.c

index 48feb032d8c107eaa6c19d97d6775a53801a7f9f..eb9c0b3d852effc3ddb5fb3a0200bc08bbd1edd5 100644 (file)
@@ -414,6 +414,9 @@ static uint16_t portid_by_device(char * device)
                }
        }
        ret_ul = strtoul(&(device[prefix_len]), &pEnd, 10);
+       if (pEnd == &(device[prefix_len]) || *pEnd != '\0'){
+               return ret;
+       }
        // too large for portid
        if (ret_ul >= DPDK_PORTID_MAX){ 
                return ret;
@@ -682,7 +685,7 @@ static int pcap_dpdk_activate(pcap_t *p)
                ret = 0; // OK
        }while(0);
 
-       if (ret == PCAP_ERROR)
+       if (ret <= PCAP_ERROR) // all kinds of error code
        {
                pcap_cleanup_live_common(p);
        }else{