command: Add command_decode_ptr() helper

Add a helper function to convert from a string buffer passed in the
args[] parameter to an actual pointer.  This avoids all the callers
needing to perfrom pointer manipulation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2020-10-29 23:54:17 -04:00
parent aaf3dc6ac3
commit 473828ca6a
10 changed files with 38 additions and 30 deletions

View File

@@ -195,7 +195,7 @@ command_tmcuart_send(uint32_t *args)
// Uart is busy - silently drop this request (host should retransmit)
return;
uint8_t write_len = args[1];
uint8_t *write = (void*)(size_t)args[2];
uint8_t *write = command_decode_ptr(args[2]);
uint8_t read_len = args[3];
if (write_len > sizeof(t->data) || read_len > sizeof(t->data))
shutdown("tmcuart data too large");