Remove gcc 12.1 warning: strncpy specified bound depends on the length of the source argument

This commit is contained in:
Philippe Teuwen 2022-05-12 22:54:11 +02:00
commit c4a8e0fa2e

View file

@ -1510,10 +1510,10 @@ static int CmdRawDemod(const char *Cmd) {
}; };
// //
size_t n = MIN(strlen(Cmd), 4); char tmp[5];
char tmp[7]; size_t n = MIN(strlen(Cmd), sizeof(tmp) - 1);
memset(tmp, 0, sizeof(tmp)); memset(tmp, 0, sizeof(tmp));
strncpy(tmp, Cmd, n); strncpy(tmp, Cmd, sizeof(tmp) - 1);
CLIExecWithReturn(ctx, tmp, argtable, false); CLIExecWithReturn(ctx, tmp, argtable, false);
bool ab = arg_get_lit(ctx, 1); bool ab = arg_get_lit(ctx, 1);