Skip to content

Commit

Permalink
hosted/dap_swd: Fix the widening of the sequence data in `dap_swd_seq…
Browse files Browse the repository at this point in the history
…_in_parity()` to avoid invoking undefined behaviour when shifting the data right
  • Loading branch information
dragonmux committed Jul 16, 2024
1 parent 71b0b66 commit aab3072
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/platforms/hosted/dap_swd.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static bool dap_swd_seq_in_parity(uint32_t *const result, const size_t clock_cyc

uint32_t data = 0;
for (size_t offset = 0; offset < clock_cycles; offset += 8U)
data |= sequence.data[offset >> 3U] << offset;
data |= (uint32_t)sequence.data[offset >> 3U] << offset;
*result = data;
uint8_t parity = calculate_odd_parity(data);
return parity == (sequence.data[4] & 1U);
Expand Down

0 comments on commit aab3072

Please sign in to comment.