-
Notifications
You must be signed in to change notification settings - Fork 3
UART Demo Projects #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rmn30/uart_test
Are you sure you want to change the base?
UART Demo Projects #18
Conversation
bdb8f34
to
c407d59
Compare
else if (state->bufferIndex < BufferSize - 1) | ||
{ | ||
state->buffer[state->bufferIndex++] = byte; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so familiar with AT command processing but is it standard to just ignore characters in a command after 32 bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a second (intentional) overflow here if there is a BufferSize length or greater command followed by \n
or \r
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the purposes of a demo, I've limited to 32-bytes. It allowed me to send a sensible input of 33 or above to see if at_state_process_input
would stop the overrun.
For example, if you send:
AT=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\r\n
The current code should read both \r and \n as new line characters. This isn't standard behaviour. Probably only \r should be used and \n should be ignored if found afterwards.
if (state->buffer[i] == '=') | ||
{ | ||
state->buffer[i] = '\0'; | ||
argument = &state->buffer[i + 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the at_command_set
handler assumes this is null terminated so I think I could trigger a crash if it isn't? Potentially a nice demo to have a compartment_error_handler
that handles this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also argument
is out of bounds if there is a BufferSize
command that ends in =
.
ATCommand commands[MaxCommands]; | ||
uint8_t commandCount; | ||
char buffer[BufferSize]; | ||
char argument[ArgumentSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field is unused.
In case you are wondering why you're not getting traps in your example it may be because we have not turned on sub-object bounds by default so all the overflows of More info: https://www.cl.cam.ac.uk/~pffm2/sosp2023_cheri_tutorial/exercises/4_subobject-bounds/README.html |
Also re. code style since this is |
Some code I've previously kept as C compatible to allow for easy binding to other languages. This was probably OK for a proof of concept, but not for the final solution. |
I need to run another pass over this, hopefully the code takes on board your C/C++ comments. Uses only carriage return now. I still need to implement compartment_error_handler. Ideally the AT commands should be case insensitive. |
9bb7e86
to
ecae44f
Compare
priority = 1, | ||
entry_point = "entry_point", | ||
stack_size = 0x800, | ||
stack_size = 0x1200, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stack sizes to be lowered in next commit.
4f456d6
to
1bf53a5
Compare
No description provided.