Fix a bunch of potential buffer overruns with CLIGetStrWithReturn :
Most prominent one was "lf pac clone --cn 123456789" causing garbage on the terminal Some changed code was valid before but as ppl tend to copy-paste to new code, better to uniformize and document usages of CLIGetStrWithReturn. Exceptions left are when filling real buffers (bin, raw,...), not strings.
This commit is contained in:
1 parent
78510f33a0
commit
153064ddfa
16 files changed
+31
-29
No files matched your search
+2
-2
@@ -256,8 +256,8 @@ CLIGetHexWithReturn(\<context\>, \<opt index\>, \<store variable\>, \<ptr to sto
|
||||
CLIGetStrWithReturn(\<context\>,\<opt index\>, \<uint8_t \*\>, \<int \*\>);
|
||||
If failed to retrieve string, it will exit fct
|
||||
|
||||
uint8_t buffer[100];
|
||||
int slen = sizeof(buffer); // <- slen MUST be the maximum number of characters that you want returned. e.g. Buffer Size
|
||||
uint8_t buffer[100] = {0};
|
||||
int slen = sizeof(buffer) - 1; // <- slen MUST be the maximum number of characters that you want returned. e.g. Buffer Size - 1 if you need it to be null-terminated!
|
||||
CLIGetStrWithReturn(ctx, 1, buffer, &slen);
|
||||
|
||||
**string option**
|
||||
|
||||
Reference in new issue
Block a user