Skip to content

Commit bd00618

Browse files
committed
Fixes the size comparison in the avtp_<format>_valid function, i.e., converts the length to octets
1 parent ed41f83 commit bd00618

File tree

10 files changed

+20
-10
lines changed

10 files changed

+20
-10
lines changed

src/avtp/acf/Can.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ uint8_t Avtp_Can_IsValid(Avtp_Can_t* pdu, size_t bufferSize)
297297
return FALSE;
298298
}
299299

300-
if (Avtp_Can_GetAcfMsgLength(pdu) > bufferSize) {
300+
// Avtp_Can_GetAcfMsgLength returns quadlets. Convert the length field to octets
301+
if (Avtp_Can_GetAcfMsgLength(pdu) * 4 > bufferSize) {
301302
return FALSE;
302303
}
303304
return TRUE;

src/avtp/acf/CanBrief.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ uint8_t Avtp_CanBrief_IsValid(Avtp_CanBrief_t* pdu, size_t bufferSize)
267267
return FALSE;
268268
}
269269

270-
if (Avtp_CanBrief_GetAcfMsgLength(pdu) > bufferSize) {
270+
// Avtp_CanBrief_GetAcfMsgLength returns quadlets. Convert the length field to octets
271+
if (Avtp_CanBrief_GetAcfMsgLength(pdu) * 4 > bufferSize) {
271272
return FALSE;
272273
}
273274

src/avtp/acf/FlexRay.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ uint8_t Avtp_FlexRay_IsValid(Avtp_FlexRay_t *pdu, size_t bufferSize)
254254
return FALSE;
255255
}
256256

257-
if (Avtp_FlexRay_GetAcfMsgLength(pdu) > bufferSize)
257+
// Avtp_FlexRay_GetAcfMsgLength returns quadlets. Convert the length field to octets
258+
if (Avtp_FlexRay_GetAcfMsgLength(pdu) * 4 > bufferSize)
258259
{
259260
return FALSE;
260261
}

src/avtp/acf/Gpc.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ uint8_t Avtp_Gpc_IsValid(Avtp_Gpc_t* pdu, size_t bufferSize)
113113
return FALSE;
114114
}
115115

116-
if (Avtp_Gpc_GetAcfMsgLength(pdu) > bufferSize) {
116+
// Avtp_Gpc_GetAcfMsgLength returns quadlets. Convert the length field to octets
117+
if (Avtp_Gpc_GetAcfMsgLength(pdu) * 4 > bufferSize) {
117118
return FALSE;
118119
}
119120

src/avtp/acf/Lin.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ uint8_t Avtp_Lin_IsValid(Avtp_Lin_t* pdu, size_t bufferSize){
160160
return FALSE;
161161
}
162162

163-
if (Avtp_Lin_GetAcfMsgLength(pdu) > bufferSize) {
163+
// Avtp_Lin_GetAcfMsgLength returns quadlets. Convert the length field to octets
164+
if (Avtp_Lin_GetAcfMsgLength(pdu) *4 > bufferSize) {
164165
return FALSE;
165166
}
166167

src/avtp/acf/Most.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ uint8_t Avtp_Most_IsValid(Avtp_Most_t *pdu, size_t bufferSize)
211211
return FALSE;
212212
}
213213

214-
if (Avtp_Most_GetAcfMsgLength(pdu) > bufferSize)
214+
// Avtp_Most_GetAcfMsgLength returns quadlets. Convert the length field to octets
215+
if (Avtp_Most_GetAcfMsgLength(pdu) * 4 > bufferSize)
215216
{
216217
return FALSE;
217218
}

src/avtp/acf/Ntscf.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ uint8_t Avtp_Ntscf_IsValid(Avtp_Ntscf_t* pdu, size_t bufferSize)
158158
return FALSE;
159159
}
160160

161-
if (Avtp_Ntscf_GetNtscfDataLength(pdu) > bufferSize) {
161+
// Avtp_Ntscf_GetNtscfDataLength returns quadlets. Convert the length field to octets
162+
if (Avtp_Ntscf_GetNtscfDataLength(pdu) * 4> bufferSize) {
162163
return FALSE;
163164
}
164165

src/avtp/acf/Sensor.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ uint8_t Avtp_Sensor_IsValid(Avtp_Sensor_t* pdu, size_t bufferSize)
163163
return FALSE;
164164
}
165165

166-
if (Avtp_Sensor_GetAcfMsgLength(pdu) > bufferSize) {
166+
// Avtp_Sensor_GetAcfMsgLength returns quadlets. Convert the length field to octets
167+
if (Avtp_Sensor_GetAcfMsgLength(pdu) *4 > bufferSize) {
167168
return FALSE;
168169
}
169170

src/avtp/acf/SensorBrief.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ uint8_t Avtp_SensorBrief_IsValid(Avtp_SensorBrief_t* pdu, size_t bufferSize)
153153
return FALSE;
154154
}
155155

156-
if(Avtp_SensorBrief_GetAcfMsgLength(pdu) > bufferSize) {
156+
// Avtp_SensorBrief_GetAcfMsgLength returns quadlets. Convert the length field to octets
157+
if(Avtp_SensorBrief_GetAcfMsgLength(pdu) *4 > bufferSize) {
157158
return FALSE;
158159
}
159160

src/avtp/acf/Tscf.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ uint8_t Avtp_Tscf_IsValid(Avtp_Tscf_t* pdu, size_t bufferSize)
217217
return FALSE;
218218
}
219219

220-
if (Avtp_Tscf_GetStreamDataLength(pdu) > bufferSize) {
220+
// Avtp_Tscf_GetStreamDataLength returns quadlets. Convert the length field to octets
221+
if (Avtp_Tscf_GetStreamDataLength(pdu) * 4 > bufferSize) {
221222
return FALSE;
222223
}
223224

0 commit comments

Comments
 (0)