mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Array overrun fix in ScalarCodec, thanks Coverity
This commit is contained in:
parent
fe57f3f5c5
commit
166ded6ba5
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user