1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
diff --git a/ClntMessages/ClntMsg.cpp b/ClntMessages/ClntMsg.cpp
index eeaadd0..0cf5dce 100644
--- a/ClntMessages/ClntMsg.cpp
+++ b/ClntMessages/ClntMsg.cpp
@@ -346,7 +346,9 @@ unsigned long TClntMsg::getTimeout()
void TClntMsg::send()
{
- char* pkt = new char[getSize()];
+ size_t size = getSize();
+ char* pkt = new char[size];
+ memset(pkt, 0, size);
srand((uint32_t)time(NULL));
if (!RC)
@@ -364,7 +366,7 @@ void TClntMsg::send()
RC++;
- this->storeSelf(pkt);
+ storeSelf(pkt);
SPtr<TIfaceIface> ptrIface = ClntIfaceMgr().getIfaceByID(Iface);
if (!ptrIface) {
diff --git a/ClntMessages/ClntMsgRequest.cpp b/ClntMessages/ClntMsgRequest.cpp
index 4a7b5da..f3e40fd 100644
--- a/ClntMessages/ClntMsgRequest.cpp
+++ b/ClntMessages/ClntMsgRequest.cpp
@@ -143,7 +143,10 @@ TClntMsgRequest::TClntMsgRequest(List(TAddrIA) IAs,
IsDone=false;
SPtr<TOpt> ptr;
ptr = new TOptDUID(OPTION_CLIENTID, ClntCfgMgr().getDUID(), this );
- Options.push_back( ptr );
+
+ if ( ptr ) {
+ Options.push_back( ptr );
+ }
if (!srvDUID) {
Log(Error) << "Unable to send REQUEST: ServerId not specified.\n" << LogEnd;
@@ -154,7 +157,9 @@ TClntMsgRequest::TClntMsgRequest(List(TAddrIA) IAs,
ptr = (Ptr*) new TOptDUID(OPTION_SERVERID, srvDUID,this);
// all IAs provided by checkSolicit
SPtr<TAddrIA> ClntAddrIA;
- Options.push_back( ptr );
+ if ( ptr ) {
+ Options.push_back( ptr );
+ }
IAs.first();
while (ClntAddrIA = IAs.get())
diff --git a/Messages/Msg.cpp b/Messages/Msg.cpp
index baa6c86..6eef6c7 100644
--- a/Messages/Msg.cpp
+++ b/Messages/Msg.cpp
@@ -66,10 +66,15 @@ int TMsg::getSize()
{
int pktsize=0;
TOptList::iterator opt;
+ int optionCount = 0;
for (opt = Options.begin(); opt!=Options.end(); ++opt)
{
- pktsize += (*opt)->getSize();
+ Log(Info) << "### CPE Debug - Option with index " << optionCount++ << LogEnd ;
+ Log(Info) << "### CPE Debug - Option with type " << (*opt)->getOptType() << LogEnd ;
+ pktsize += (*opt)->getSize();
}
+ Log(Info) << "### CPE Debug - Packet size of option (Add 4) " << pktsize << LogEnd ;
+
return pktsize + 4;
}
|