fix(rx): reject undersized typed frames safely

This commit is contained in:
2026-08-28 14:54:06 +03:00
parent 36f234739a
commit c7efd1cb65
4 changed files with 299 additions and 15 deletions

View File

@ -9,18 +9,19 @@ namespace PacketTypes
friend IR_Decoder;
protected:
bool isAvailable;
bool isRawAvailable;
bool isNeedAccept;
bool isAvailable = false;
bool isRawAvailable = false;
bool isNeedAccept = false;
uint8_t msgOffset;
uint8_t addressFromOffset;
uint8_t addressToOffset;
uint8_t DataOffset;
uint8_t msgOffset = 0;
uint8_t addressFromOffset = 0;
uint8_t addressToOffset = 0;
uint8_t DataOffset = 0;
IR_FOX::PackInfo *packInfo;
uint16_t id;
IR_FOX::PackInfo *packInfo = nullptr;
uint16_t id = 0;
virtual bool checkPacketLayout() const;
virtual bool checkAddress();
void set(IR_FOX::PackInfo *packInfo, uint16_t id);
@ -34,9 +35,9 @@ namespace PacketTypes
bool available();
bool availableRaw();
inline uint8_t getMsgInfo() { return packInfo->buffer[0] & IR_MASK_MSG_INFO; };
inline uint8_t getMsgType() { return (packInfo->buffer[0] >> 5) & IR_MASK_MSG_TYPE; };
inline uint8_t getMsgRAW() { return packInfo->buffer[0]; };
inline uint8_t getMsgInfo() { return packInfo != nullptr && packInfo->buffer != nullptr ? packInfo->buffer[0] & IR_MASK_MSG_INFO : 0U; };
inline uint8_t getMsgType() { return packInfo != nullptr && packInfo->buffer != nullptr ? (packInfo->buffer[0] >> 5) & IR_MASK_MSG_TYPE : 0U; };
inline uint8_t getMsgRAW() { return packInfo != nullptr && packInfo->buffer != nullptr ? packInfo->buffer[0] : 0U; };
inline uint16_t getErrorCount() { return packInfo->err.all(); };
inline uint8_t getErrorLowSignal() { return packInfo->err.lowSignal; };
inline uint8_t getErrorHighSignal() { return packInfo->err.highSignal; };
@ -65,6 +66,7 @@ namespace PacketTypes
inline uint8_t *getDataPrt() { return _getDataPrt(this); };
private:
bool checkPacketLayout() const override;
bool checkAddress() override;
};
@ -86,6 +88,7 @@ namespace PacketTypes
inline uint8_t *getDataPrt() { return _getDataPrt(this); };
private:
bool checkPacketLayout() const override;
bool checkAddress() override;
};
@ -103,6 +106,7 @@ namespace PacketTypes
inline uint8_t getCustomByte() { return packInfo->buffer[DataOffset]; };
private:
bool checkPacketLayout() const override;
bool checkAddress() override;
};
@ -121,6 +125,7 @@ namespace PacketTypes
inline uint16_t getAddrTo() { return _getAddrTo(this); };
private:
bool checkPacketLayout() const override;
bool checkAddress() override;
};