@@ -61,14 +61,14 @@ namespace pcpp
61
61
return false ;
62
62
}
63
63
64
- if (m_Packet == nullptr )
64
+ if (( size_t )offsetInLayer > m_DataLen )
65
65
{
66
- if ((size_t )offsetInLayer > m_DataLen)
67
- {
68
- PCPP_LOG_ERROR (" Requested offset is larger than data length" );
69
- return false ;
70
- }
66
+ PCPP_LOG_ERROR (" Requested offset is larger than data length" );
67
+ return false ;
68
+ }
71
69
70
+ if (m_Packet == nullptr )
71
+ {
72
72
uint8_t * newData = new uint8_t [m_DataLen + numOfBytesToExtend];
73
73
memcpy (newData, m_Data, offsetInLayer);
74
74
memcpy (newData + offsetInLayer + numOfBytesToExtend, m_Data + offsetInLayer, m_DataLen - offsetInLayer);
@@ -78,12 +78,6 @@ namespace pcpp
78
78
return true ;
79
79
}
80
80
81
- if ((size_t )offsetInLayer > m_DataLen)
82
- {
83
- PCPP_LOG_ERROR (" Requested offset is larger than data length" );
84
- return false ;
85
- }
86
-
87
81
if (m_Data - m_Packet->m_RawPacket ->getRawData () + (ptrdiff_t )offsetInLayer
88
82
> (ptrdiff_t )m_Packet->m_RawPacket ->getRawDataLen ())
89
83
{
@@ -108,14 +102,14 @@ namespace pcpp
108
102
return false ;
109
103
}
110
104
111
- if (m_Packet == nullptr )
105
+ if (( size_t )offsetInLayer >= m_DataLen )
112
106
{
113
- if ((size_t )offsetInLayer >= m_DataLen)
114
- {
115
- PCPP_LOG_ERROR (" Requested offset is larger than data length" );
116
- return false ;
117
- }
107
+ PCPP_LOG_ERROR (" Requested offset is larger than data length" );
108
+ return false ;
109
+ }
118
110
111
+ if (m_Packet == nullptr )
112
+ {
119
113
uint8_t * newData = new uint8_t [m_DataLen - numOfBytesToShorten];
120
114
memcpy (newData, m_Data, offsetInLayer);
121
115
memcpy (newData + offsetInLayer, m_Data + offsetInLayer + numOfBytesToShorten,
@@ -126,12 +120,6 @@ namespace pcpp
126
120
return true ;
127
121
}
128
122
129
- if ((size_t )offsetInLayer >= m_DataLen)
130
- {
131
- PCPP_LOG_ERROR (" Requested offset is larger than data length" );
132
- return false ;
133
- }
134
-
135
123
if ((size_t )offsetInLayer + numOfBytesToShorten > m_DataLen)
136
124
{
137
125
PCPP_LOG_ERROR (" Requested number of bytes to shorten is larger than data length" );
0 commit comments