From: Christian Herdtweck Date: Thu, 12 Mar 2015 17:02:30 +0000 (+0100) Subject: fixed bug in reading of checksum (which was found using the unittests -- great thing!) X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=8f07c5f0380650886ceca46066e76c11962fddbc;p=pingcheck fixed bug in reading of checksum (which was found using the unittests -- great thing!) --- diff --git a/src/icmp/icmpheader.cpp b/src/icmp/icmpheader.cpp index b2e1346..d8df8c7 100644 --- a/src/icmp/icmpheader.cpp +++ b/src/icmp/icmpheader.cpp @@ -21,6 +21,7 @@ */ #include "icmp/icmpheader.h" +#include #include std::istream& IcmpHeader::read(std::istream &is) @@ -29,8 +30,10 @@ std::istream& IcmpHeader::read(std::istream &is) is.read(buf.get(), 4); type = static_cast(buf[0]); code = static_cast(buf[1]); - checksum = ( static_cast(buf[2]) << 8 ) - + static_cast(buf[3]); + uint8_t checksum_msb = static_cast(buf[2]); + uint8_t checksum_lsb = static_cast(buf[3]); + checksum = ( static_cast(checksum_msb) << 8 ) + + static_cast(checksum_lsb); return is; }