Skip to content

Commit f4fc0d8

Browse files
authored
host_cmd: zero-initialize response buffer (#215)
Unit tests that don't appropriately mock host command responses in `libhoth_receive_response` will cause `resp.hdr` and `resp.payload_buf` to be uninitialized. Using `resp` in ```c status = validate_ec_response_header(&resp.hdr, resp.payload_buf, resp_size); ``` will access uninitialized memory.
1 parent 691f27f commit f4fc0d8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

protocol/host_cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ int libhoth_hostcmd_exec(struct libhoth_device* dev, uint16_t command,
186186
struct hoth_host_response hdr;
187187
uint8_t
188188
payload_buf[LIBHOTH_MAILBOX_SIZE - sizeof(struct hoth_host_response)];
189-
} resp;
190-
size_t resp_size;
189+
} resp = {};
190+
size_t resp_size = 0;
191191
status = libhoth_receive_response(dev, &resp, sizeof(resp), &resp_size,
192192
HOTH_CMD_TIMEOUT_MS_DEFAULT);
193193
if (status != LIBHOTH_OK) {

0 commit comments

Comments
 (0)