File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 4343#include " Poco/Foundation.h"
4444#include " Poco/Net/Socket.h"
4545#include " Poco/Net/ICMPPacketImpl.h"
46+ #include < cstddef>
4647
4748
4849namespace Poco {
@@ -67,6 +68,12 @@ class Net_API ICMPv4PacketImpl : public ICMPPacketImpl
6768 Poco::UInt16 seq;
6869 };
6970
71+ // compile-time shield against misalignment
72+ poco_static_assert (offsetof(Header, code) == 0x01 );
73+ poco_static_assert (offsetof(Header, checksum) == 0x02 );
74+ poco_static_assert (offsetof(Header, id) == 0x04 );
75+ poco_static_assert (offsetof(Header, seq) == 0x06 );
76+
7077 enum MessageType
7178 {
7279 ECHO_REPLY,
@@ -175,7 +182,7 @@ class Net_API ICMPv4PacketImpl : public ICMPPacketImpl
175182 static const std::string REDIRECT_MESSAGE_CODE[REDIRECT_MESSAGE_LENGTH];
176183 static const std::string TIME_EXCEEDED_CODE[TIME_EXCEEDED_LENGTH];
177184 static const std::string PARAMETER_PROBLEM_CODE[PARAMETER_PROBLEM_LENGTH];
178-
185+
179186 Poco::UInt16 _seq;
180187};
181188
Original file line number Diff line number Diff line change @@ -125,8 +125,9 @@ const std::string ICMPv4PacketImpl::PARAMETER_PROBLEM_CODE[] =
125125};
126126
127127
128- ICMPv4PacketImpl::ICMPv4PacketImpl (int dataSize):
129- ICMPPacketImpl (dataSize)
128+ ICMPv4PacketImpl::ICMPv4PacketImpl (int dataSize)
129+ : ICMPPacketImpl(dataSize),
130+ _seq (0 )
130131{
131132 initPacket ();
132133}
You can’t perform that action at this time.
0 commit comments