Skip to content

Commit

Permalink
x8h7: sanitize malformed packets
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed May 14, 2024
1 parent f9fb641 commit 97358c2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions recipes-kernel/kernel-modules/x8h7/x8h7_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ void pkt_dump(char *title, void *data)
for (i=0; i<pkt->size; i++) {
data_len += sprintf(data_str + data_len, " %02X", ptr[i]);
}
if (pkt->peripheral == 0 || pkt->size == 0) {
return;
}
printk("- PKT peripheral: %d %s, opcode: %d, size: %d data: %s\n",
pkt->peripheral, to_peripheral_string(pkt->peripheral),
pkt->opcode, pkt->size, data_str);
Expand Down Expand Up @@ -293,6 +296,9 @@ static int pkt_parse(struct spidev_data *spidev)

i = pkt->peripheral;
if (i < X8H7_PERIPH_NUM) {
if (pkt->peripheral == 0 || pkt->size == 0) {
return 0;
}
if (x8h7_hook[i]) {
x8h7_pkt_t p;
p.peripheral = pkt->peripheral;
Expand Down

0 comments on commit 97358c2

Please sign in to comment.