From 6bdc3bd98fd899f48b792f9d1ae82a313c159450 Mon Sep 17 00:00:00 2001 From: wenxian li Date: Thu, 24 Mar 2016 01:41:10 -0400 Subject: [PATCH] Fix crash when # of mac-ip mapping entries exceed than 255. --- src/tuple_gen.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/tuple_gen.cpp b/src/tuple_gen.cpp index d3538ce6..36f70c39 100755 --- a/src/tuple_gen.cpp +++ b/src/tuple_gen.cpp @@ -84,13 +84,16 @@ void CClientPool::Create(IP_DIST_t dist_value, if (total_ip > ((l_flow*t_cps/MAX_PORT))) { if (has_mac_map) { + int skip_cnt=0; for(int idx=0;idxget_mac_addr_by_ip( min_ip+idx); if (mac_adr != NULL) { - m_ip_info[idx] = new CClientInfoL(has_mac_map); - m_ip_info[idx]->set_ip(min_ip+idx); - m_ip_info[idx]->set_mac(mac_adr); + m_ip_info[idx-skip_cnt] = new CClientInfoL(has_mac_map); + m_ip_info[idx-skip_cnt]->set_ip(min_ip+idx); + m_ip_info[idx-skip_cnt]->set_mac(mac_adr); + } else { + skip_cnt++; } } } else { @@ -101,13 +104,16 @@ void CClientPool::Create(IP_DIST_t dist_value, } } else { if (has_mac_map) { + int skip_cnt=0; for(int idx=0;idxget_mac_addr_by_ip(min_ip+idx); if (mac_adr != NULL) { - m_ip_info[idx] = new CClientInfo(has_mac_map); - m_ip_info[idx]->set_ip(min_ip+idx); - m_ip_info[idx]->set_mac(mac_adr); + m_ip_info[idx-skip_cnt] = new CClientInfo(has_mac_map); + m_ip_info[idx-skip_cnt]->set_ip(min_ip+idx); + m_ip_info[idx-skip_cnt]->set_mac(mac_adr); + } else { + skip_cnt++; } } } else { -- 2.16.6