From 30b2431b3ac5568c6a4498d95f9617846eda8ff3 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 5 Jan 2017 01:35:16 +0100 Subject: [PATCH] Replaced a memory comparison in the PCap handling code with an equivalent integer comparison. --- src/ne2000.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ne2000.c b/src/ne2000.c index ae0f12afd..60a21e01c 100644 --- a/src/ne2000.c +++ b/src/ne2000.c @@ -1515,6 +1515,8 @@ void ne2000_poller(void *p) struct queuepacket *qp; const unsigned char *data; struct pcap_pkthdr h; + uint32_t mac_cmp32[2]; + uint16_t mac_cmp16[2]; int res; @@ -1538,7 +1540,14 @@ if(net_is_pcap && net_pcap!=NULL) { data=_pcap_next(net_pcap,&h); if(data==0x0){goto WTF;} - if((memcmp(data+6,maclocal,6))==0) + /* Received. */ + mac_cmp32[0] = *(uint32_t *) (data+6); + mac_cmp16[0] = *(uint16_t *) (data+10); + /* Local. */ + mac_cmp32[1] = *(uint32_t *) (maclocal); + mac_cmp16[1] = *(uint16_t *) (maclocal+4); + // if((memcmp(data+6,maclocal,6))==0) + if ((mac_cmp32[0] == mac_cmp32[1]) && (mac_cmp16[0] == mac_cmp16[1])) ne2000_log("ne2000 we just saw ourselves\n"); else { if((ne2000->DCR.loop == 0) || (ne2000->TCR.loop_cntl != 0))