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
@@ -236,8 +236,8 @@ static int CmdPacClone(const char *Cmd) {
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
|
||||
uint8_t cnstr[9];
|
||||
int cnlen = 9;
|
||||
uint8_t cnstr[9] = {0};
|
||||
int cnlen = sizeof(cnstr) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
|
||||
memset(cnstr, 0x00, sizeof(cnstr));
|
||||
CLIGetStrWithReturn(ctx, 1, cnstr, &cnlen);
|
||||
|
||||
@@ -329,7 +329,7 @@ static int CmdPacSim(const char *Cmd) {
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
|
||||
uint8_t cnstr[10];
|
||||
int cnlen = 9;
|
||||
int cnlen = sizeof(cnstr) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
|
||||
memset(cnstr, 0x00, sizeof(cnstr));
|
||||
CLIGetStrWithReturn(ctx, 1, cnstr, &cnlen);
|
||||
|
||||
|
||||
Reference in new issue
Block a user