diff --git a/src/dsr/model/dsr-options.cc b/src/dsr/model/dsr-options.cc index 027c756e3..e9a1f55da 100644 --- a/src/dsr/model/dsr-options.cc +++ b/src/dsr/model/dsr-options.cc @@ -1313,7 +1313,8 @@ uint8_t DsrOptionSR::Process (Ptr packet, Ptr dsrP, Ipv4Address m_dropTrace (packet); return 0; } - if (numberAddress - segsLeft - 2 < 0) // The index is invalid + // -fstrict-overflow sensitive, see bug 1868 + if (numberAddress - segsLeft < 2) // The index is invalid { NS_LOG_LOGIC ("Malformed header. Drop!"); m_dropTrace (packet); diff --git a/src/internet/model/icmpv6-header.cc b/src/internet/model/icmpv6-header.cc index 9466a277b..aa4cac5bc 100644 --- a/src/internet/model/icmpv6-header.cc +++ b/src/internet/model/icmpv6-header.cc @@ -1910,10 +1910,11 @@ uint32_t Icmpv6OptionLinkLayerAddress::Deserialize (Buffer::Iterator start) SetType (i.ReadU8 ()); SetLength (i.ReadU8 ()); - NS_ASSERT (GetLength () * 8 - 2 <= 32); + // -fstrict-overflow sensitive, see bug 1868 + NS_ASSERT (GetLength () * 8 <= 32 + 2); i.Read (mac, (GetLength () * 8) - 2); - m_addr.CopyFrom (mac, (GetLength () * 8)-2); + m_addr.CopyFrom (mac, (GetLength () * 8) - 2); return GetSerializedSize (); } diff --git a/src/internet/model/ipv4-header.cc b/src/internet/model/ipv4-header.cc index c131eb86e..714e03100 100644 --- a/src/internet/model/ipv4-header.cc +++ b/src/internet/model/ipv4-header.cc @@ -247,7 +247,8 @@ uint16_t Ipv4Header::GetFragmentOffset (void) const { NS_LOG_FUNCTION (this); - if ((m_fragmentOffset+m_payloadSize+5*4) > 65535) + // -fstrict-overflow sensitive, see bug 1868 + if ( m_fragmentOffset + m_payloadSize > 65535 - 5*4 ) { NS_LOG_WARN("Fragment will exceed the maximum packet size once reassembled"); } diff --git a/src/lte/model/lte-mi-error-model.cc b/src/lte/model/lte-mi-error-model.cc index 98aaf9c63..1c99d64c6 100644 --- a/src/lte/model/lte-mi-error-model.cc +++ b/src/lte/model/lte-mi-error-model.cc @@ -657,7 +657,8 @@ LteMiErrorModel::GetTbDecodificationStats (const SpectrumValue& sinr, const std: else { // second segmentation size: K- = maximum K in table such that K < K+ - Kminus = cbSizeTable[KplusId-1 > 0 ? KplusId-1 : 0]; + // -fstrict-overflow sensitive, see bug 1868 + Kminus = cbSizeTable[ KplusId > 1 ? KplusId - 1 : 0]; deltaK = Kplus - Kminus; Cminus = floor ((((double) C * Kplus) - (double)B1) / (double)deltaK); Cplus = C - Cminus; diff --git a/src/mesh/model/dot11s/ie-dot11s-perr.cc b/src/mesh/model/dot11s/ie-dot11s-perr.cc index e04f8c3cd..f5870953b 100644 --- a/src/mesh/model/dot11s/ie-dot11s-perr.cc +++ b/src/mesh/model/dot11s/ie-dot11s-perr.cc @@ -108,7 +108,12 @@ IePerr::AddAddressUnit (HwmpProtocol::FailedDestination unit) bool IePerr::IsFull () const { - return (GetInformationFieldSize () + 2 /* ID + LENGTH*/+ 10 /* Size of Mac48Address + uint32_t (one unit)*/> 255); + // -fstrict-overflow sensitive, see bug 1868 + return (GetInformationFieldSize () + > 255 + - 2 /* ID + LENGTH*/ + - 10 /* Size of Mac48Address + uint32_t (one unit)*/ + ); } std::vector IePerr::GetAddressUnitVector () const diff --git a/src/mesh/model/dot11s/ie-dot11s-preq.cc b/src/mesh/model/dot11s/ie-dot11s-preq.cc index 67fe4f383..4b8fd9995 100644 --- a/src/mesh/model/dot11s/ie-dot11s-preq.cc +++ b/src/mesh/model/dot11s/ie-dot11s-preq.cc @@ -423,7 +423,8 @@ IePreq::MayAddAddress (Mac48Address originator) { return false; } - if ((GetInformationFieldSize () + 11) > 255) + // -fstrict-overflow sensitive, see bug 1868 + if ( GetInformationFieldSize () > 255 - 11 ) { return false; } @@ -432,7 +433,8 @@ IePreq::MayAddAddress (Mac48Address originator) bool IePreq::IsFull () const { - return ((GetInformationFieldSize () + 11) > 255); + // -fstrict-overflow sensitive, see bug 1868 + return ( GetInformationFieldSize () > 255 - 11 ); } std::ostream & operator << (std::ostream &os, const IePreq &a)