Permalink
Browse files

fix a memory leak in the dlpi arp scanning stuff

  • Loading branch information...
postwait committed Oct 9, 2013
1 parent 81086f2 commit 1f07cc5a6d13ad34240567d9f7e7dc152d38d65c
Showing with 15 additions and 14 deletions.
  1. +13 −12 arpcache-dlpi.cc
  2. +2 −2 package.json
View
@@ -124,18 +124,19 @@ int sample_arp_cache(arp_entry **l) {
if(req->level == MIB2_IP && req->name == 0) {
ip = (mib2_ip_t *)dbuf;
}
- if(!ip || req->level != MIB2_IP || req->name != MIB2_IP_MEDIA) continue;
- for(np = (mib2_ipNetToMediaEntry_t *)dbuf;
- (char *)np < (char *)dbuf + databuf.len;
- np = (mib2_ipNetToMediaEntry_t *)((char *)np + ip->ipNetToMediaEntrySize)) {
- if(count >= arpcache_psize) {
- arpcache_psize <<= 1;
- arpcache_private = (arp_entry *)realloc(arpcache_private, sizeof(arp_entry)*(arpcache_psize+1));
- }
- if(np->ipNetToMediaPhysAddress.o_length == ETH_ALEN) {
- arpcache_private[count].ipaddr.s_addr = np->ipNetToMediaNetAddress;
- memcpy(arpcache_private[count].mac, np->ipNetToMediaPhysAddress.o_bytes, ETH_ALEN);
- count++;
+ if(ip && req->level == MIB2_IP && req->name == MIB2_IP_MEDIA) {
+ for(np = (mib2_ipNetToMediaEntry_t *)dbuf;
+ (char *)np < (char *)dbuf + databuf.len;
+ np = (mib2_ipNetToMediaEntry_t *)((char *)np + ip->ipNetToMediaEntrySize)) {
+ if(count >= arpcache_psize) {
+ arpcache_psize <<= 1;
+ arpcache_private = (arp_entry *)realloc(arpcache_private, sizeof(arp_entry)*(arpcache_psize+1));
+ }
+ if(np->ipNetToMediaPhysAddress.o_length == ETH_ALEN) {
+ arpcache_private[count].ipaddr.s_addr = np->ipNetToMediaNetAddress;
+ memcpy(arpcache_private[count].mac, np->ipNetToMediaPhysAddress.o_bytes, ETH_ALEN);
+ count++;
+ }
}
}
free(dbuf);
View
@@ -1,7 +1,7 @@
{ "name" : "ife"
, "description" : "Interface Management for Node.js"
, "keywords" : [ "ife", "ifconfig", "ipconfig" ]
-, "version" : "0.0.3"
+, "version" : "0.0.4"
, "preferGlobal" : true
, "author" : { "name" : "Theo Schlossnagle" }
, "repository" :
@@ -12,7 +12,7 @@
{ "url" : "http://github.com/postwait/node-ife/issues"
}
, "main" : "./index"
-, "engines" : { "node" : "0.4 || 0.5 || 0.6 || 0.8 || 0.10" }
+, "engines" : { "node" : "0.6 || 0.8 || 0.10" }
, "licenses" :
[ { "type" : "MIT"
, "url" : "http://github.com/postwait/node-ife/raw/master/LICENSE-MIT"

0 comments on commit 1f07cc5

Please sign in to comment.