tools: check properties given by user for syntax errors

Check JSON passed in by user for syntax errors before processing it.
This commit is contained in:
Pauli Virtanen 2024-03-24 16:11:26 +02:00
parent 0da9255057
commit 026d55df62
5 changed files with 54 additions and 11 deletions

View file

@ -110,7 +110,7 @@ int main(int argc, char *argv[])
{ "playback-props", required_argument, NULL, 'o' },
{ NULL, 0, NULL, 0}
};
int c, res = -1;
int c, res = -1, line, col;
setlocale(LC_ALL, "");
pw_init(&argc, &argv);
@ -170,9 +170,17 @@ int main(int argc, char *argv[])
pw_properties_set(data.playback_props, PW_KEY_TARGET_OBJECT, optarg);
break;
case 'i':
if (!pw_properties_check_string(optarg, strlen(optarg), &line, &col)) {
fprintf(stderr, "error: syntax error in --capture-props at line:%d col:%d\n", line, col);
return -1;
}
pw_properties_update_string(data.capture_props, optarg, strlen(optarg));
break;
case 'o':
if (!pw_properties_check_string(optarg, strlen(optarg), &line, &col)) {
fprintf(stderr, "error: syntax error in --playback-props at line:%d col:%d\n", line, col);
return -1;
}
pw_properties_update_string(data.playback_props, optarg, strlen(optarg));
break;
default: