Skip to content

Commit

Permalink
target/esp_xtensa_apptrace: fix ub issue due to casting (char *) to (…
Browse files Browse the repository at this point in the history
…uint32 *):
  • Loading branch information
erhankur committed Feb 1, 2021
1 parent 7c87f2f commit de9e630
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/target/esp_xtensa_apptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,11 @@ static int esp_xtensa_apptrace_queue_reverse_write(struct xtensa *xtensa, uint32
}
/* write full dwords */
for (uint32_t k = bsz; k >= sizeof(uint32_t); k -= sizeof(uint32_t)) {
uint32_t temp = 0;
memcpy(&temp, cur_buf - sizeof(uint32_t), sizeof(uint32_t));
res =
xtensa_queue_dbg_reg_write(xtensa, NARADR_TRAXDATA,
*((uint32_t *)(void *)(cur_buf-sizeof(uint32_t))));
temp);
if (res != ERROR_OK)
return res;
cur_buf -= sizeof(uint32_t);
Expand Down Expand Up @@ -546,9 +548,11 @@ static int esp_xtensa_apptrace_queue_normal_write(struct xtensa *xtensa, uint32_
}
/* write full dwords */
for (uint32_t k = 0; (k+sizeof(uint32_t)) <= bsz; k += sizeof(uint32_t)) {
uint32_t temp = 0;
memcpy(&temp, cur_buf, sizeof(uint32_t));
res =
xtensa_queue_dbg_reg_write(xtensa, NARADR_TRAXDATA,
*((uint32_t *)(void *)cur_buf));
temp);
if (res != ERROR_OK)
return res;
cur_buf += sizeof(uint32_t);
Expand Down

0 comments on commit de9e630

Please sign in to comment.