diff options
author | Ido Barnea <ibarnea@cisco.com> | 2016-03-28 10:10:32 +0300 |
---|---|---|
committer | Ido Barnea <ibarnea@cisco.com> | 2016-03-28 10:10:32 +0300 |
commit | dd5fb4a71be0964d9a904af02b4010d87f28f66b (patch) | |
tree | 39c13cef15c2600341829d3e4e904e5073c73660 /src/flow_stat_parser.cpp | |
parent | 68ed79b989008006897108c7978d5c65fef47711 (diff) |
fix valgrind faiulre. Read memory of too short packet
Diffstat (limited to 'src/flow_stat_parser.cpp')
-rw-r--r-- | src/flow_stat_parser.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/flow_stat_parser.cpp b/src/flow_stat_parser.cpp index 53aa650e..200c19c9 100644 --- a/src/flow_stat_parser.cpp +++ b/src/flow_stat_parser.cpp @@ -33,15 +33,15 @@ void CFlowStatParser::reset() { int CFlowStatParser::parse(uint8_t *p, uint16_t len) { EthernetHeader *ether = (EthernetHeader *)p; - int min_len = 14 + IPV4_HDR_LEN; - + int min_len = ETH_HDR_LEN + IPV4_HDR_LEN; reset(); + if (len < min_len) + return -1; + switch( ether->getNextProtocol() ) { case EthernetHeader::Protocol::IP : - if (len < min_len) - return -1; - m_ipv4 = (IPHeader *)(p + 14); + m_ipv4 = (IPHeader *)(p + ETH_HDR_LEN); m_stat_supported = true; break; case EthernetHeader::Protocol::VLAN : @@ -143,15 +143,15 @@ int CFlowStatParser::test() { // In 82599 10G card we do not support VLANs int C82599Parser::parse(uint8_t *p, uint16_t len) { EthernetHeader *ether = (EthernetHeader *)p; - int min_len = 14 + IPV4_HDR_LEN; - + int min_len = ETH_HDR_LEN + IPV4_HDR_LEN; reset(); + if (len < min_len) + return -1; + switch( ether->getNextProtocol() ) { case EthernetHeader::Protocol::IP : - if (len < min_len) - return -1; - m_ipv4 = (IPHeader *)(p + 14); + m_ipv4 = (IPHeader *)(p + ETH_HDR_LEN); m_stat_supported = true; break; default: |