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
@@ -189,8 +189,8 @@ static int CmdPrescoClone(const char *Cmd) {
|
||||
uint8_t hex[4] = {0, 0, 0, 0};
|
||||
CLIGetHexWithReturn(ctx, 1, hex, &hex_len);
|
||||
|
||||
uint8_t idstr[11];
|
||||
int slen = 9;
|
||||
uint8_t idstr[10];
|
||||
int slen = sizeof(idstr) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
|
||||
memset(idstr, 0x00, sizeof(idstr));
|
||||
CLIGetStrWithReturn(ctx, 2, idstr, &slen);
|
||||
|
||||
@@ -292,8 +292,8 @@ static int CmdPrescoSim(const char *Cmd) {
|
||||
uint8_t hex[4] = {0, 0, 0, 0};
|
||||
CLIGetHexWithReturn(ctx, 1, hex, &hex_len);
|
||||
|
||||
uint8_t idstr[11];
|
||||
int slen = 9;
|
||||
uint8_t idstr[10] = {0};
|
||||
int slen = sizeof(idstr) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
|
||||
memset(idstr, 0x00, sizeof(idstr));
|
||||
CLIGetStrWithReturn(ctx, 2, idstr, &slen);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
Reference in new issue
Block a user