strncpy is not safe + memory optimization

This commit is contained in:
Philippe G
2021-11-03 22:00:07 -07:00
parent 2146014f04
commit 974ff5fa68
6 changed files with 12 additions and 8 deletions

View File

@@ -611,6 +611,7 @@ static int do_i2s_cmd(int argc, char **argv)
}
if(i2s_args.model_name->count>0 && strlen(i2s_args.model_name->sval[0])>0){
strncpy(i2s_dac_pin.model,i2s_args.model_name->sval[0],sizeof(i2s_dac_pin.model));
i2s_dac_pin.model[sizeof(i2s_dac_pin.model) - 1] = '\0';
}
if(!nerrors ){
fprintf(f,"Storing i2s parameters.\n");