mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-27 08:30:35 +08:00
Array overrun fix in ScalarCodec, thanks Coverity
This commit is contained in:
@@ -116,7 +116,8 @@ public:
|
||||
convertByteOrder<BitLen>(byte_union.bytes);
|
||||
|
||||
// Underlying stream class assumes that more significant bits have lower index, so we need to shift some.
|
||||
byte_union.bytes[BitLen / 8] <<= (8 - (BitLen % 8)) & 7;
|
||||
if (BitLen % 8)
|
||||
byte_union.bytes[BitLen / 8] <<= (8 - (BitLen % 8)) & 7;
|
||||
|
||||
return stream_.write(byte_union.bytes, BitLen);
|
||||
}
|
||||
@@ -136,7 +137,8 @@ public:
|
||||
if (read_res <= 0)
|
||||
return read_res;
|
||||
|
||||
byte_union.bytes[BitLen / 8] >>= (8 - (BitLen % 8)) & 7; // As in encode(), vice versa
|
||||
if (BitLen % 8)
|
||||
byte_union.bytes[BitLen / 8] >>= (8 - (BitLen % 8)) & 7; // As in encode(), vice versa
|
||||
|
||||
convertByteOrder<BitLen>(byte_union.bytes);
|
||||
fixTwosComplement<BitLen>(byte_union.value);
|
||||
|
||||
Reference in New Issue
Block a user