Skip to content

Commit

Permalink
mgmt: ec_host_cmd: clear response buffer every command
Browse files Browse the repository at this point in the history
The response buffer has to be cleared every command not to pass
unintended content e.g. response from a previous command, or stack
content.

Signed-off-by: Dawid Niedzwiecki <[email protected]>
  • Loading branch information
niedzwiecki-dawid authored and carlescufi committed Jul 7, 2023
1 parent f2d6e0f commit 521f0ba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions subsys/mgmt/ec_host_cmd/ec_host_cmd_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ FUNC_NORETURN static void ec_host_cmd_thread(void *hc_handle, void *arg2, void *
continue;
}

/*
* Pre-emptively clear the entire response buffer so we do not
* have any left over contents from previous host commands.
*/
memset(args.output_buf, 0, args.output_buf_max);

status = found_handler->handler(&args);

ec_host_cmd_send_response(status, &args);
Expand Down

0 comments on commit 521f0ba

Please sign in to comment.