CANPacket: Fix invalid length check

This case is already checked above, and further
was invalid since the length had already been
translated to the numeric (0-64) value.
pull/35/head
Paul Hollinsky 2021-05-25 17:23:41 -04:00
parent 21e93d1f73
commit d4f6c12394
1 changed files with 1 additions and 1 deletions

View File

@ -109,7 +109,7 @@ bool HardwareCANPacket::EncodeFromMessage(const CANMessage& message, std::vector
const optional<uint8_t> lenFromDLC = CANFD_DLCToLength(message.dlcOnWire); const optional<uint8_t> lenFromDLC = CANFD_DLCToLength(message.dlcOnWire);
if (lenFromDLC.has_value() && *lenFromDLC != 0) { if (lenFromDLC.has_value() && *lenFromDLC != 0) {
if (*lenFromDLC < lengthNibble || *lenFromDLC > 0xF) { if (*lenFromDLC < lengthNibble) {
report(APIEvent::Type::MessageMaxLengthExceeded, APIEvent::Severity::Error); report(APIEvent::Type::MessageMaxLengthExceeded, APIEvent::Severity::Error);
return false; return false;
} }