coverity fix 226278 and offset computation as side effect
This commit is contained in:
@@ -1642,7 +1642,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||||||
struct p {
|
struct p {
|
||||||
uint8_t flag;
|
uint8_t flag;
|
||||||
uint16_t offset;
|
uint16_t offset;
|
||||||
uint8_t *data;
|
uint8_t data[PM3_CMD_DATA_SIZE - sizeof(uint8_t) - sizeof(uint16_t)];
|
||||||
} PACKED;
|
} PACKED;
|
||||||
struct p *payload = (struct p *)packet->data.asBytes;
|
struct p *payload = (struct p *)packet->data.asBytes;
|
||||||
|
|
||||||
@@ -1654,11 +1654,11 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 40 000 - (512-3) 509 = 39491
|
// 40 000 - (512-3) 509 = 39491
|
||||||
uint16_t offset = MIN(BIGBUF_SIZE - PM3_CMD_DATA_SIZE - 3, payload->offset);
|
uint16_t offset = MIN(BIGBUF_SIZE - sizeof(payload->data), payload->offset);
|
||||||
|
|
||||||
// need to copy len bytes of data, not PM3_CMD_DATA_SIZE - 3 - offset
|
// need to copy len bytes of data, not PM3_CMD_DATA_SIZE - 3 - offset
|
||||||
// ensure len bytes copied wont go past end of bigbuf
|
// ensure len bytes copied wont go past end of bigbuf
|
||||||
uint16_t len = MIN(BIGBUF_SIZE - offset, PM3_CMD_DATA_SIZE - 3);
|
uint16_t len = MIN(BIGBUF_SIZE - offset, sizeof(payload->data));
|
||||||
|
|
||||||
uint8_t *mem = BigBuf_get_addr();
|
uint8_t *mem = BigBuf_get_addr();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user