json: spa_json_get_string() writes up to len chars or fail

This commit is contained in:
Wim Taymans 2022-01-04 10:42:32 +01:00
parent 68b31d37d9
commit c46113faa3
17 changed files with 26 additions and 26 deletions

View file

@ -165,7 +165,7 @@ static int do_extension_stream_restore_read(struct client *client, uint32_t comm
if (spa_json_enter_object(&it[0], &it[1]) <= 0)
continue;
while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) {
while (spa_json_get_string(&it[1], key, sizeof(key)) > 0) {
if (spa_streq(key, "volume")) {
if (spa_json_get_float(&it[1], &volume) <= 0)
continue;

View file

@ -42,7 +42,7 @@ static int bluez_card_object_message_handler(struct pw_manager *m, struct pw_man
return -EINVAL;
spa_json_init(&it, params, strlen(params));
if (spa_json_get_string(&it, codec, sizeof(codec)-1) <= 0)
if (spa_json_get_string(&it, codec, sizeof(codec)) <= 0)
return -EINVAL;
codec_id = atoi(codec);

View file

@ -771,7 +771,7 @@ static int json_object_find(const char *obj, const char *key, char *value, size_
if (spa_json_enter_object(&it[0], &it[1]) <= 0)
return -EINVAL;
while (spa_json_get_string(&it[1], k, sizeof(k)-1) > 0) {
while (spa_json_get_string(&it[1], k, sizeof(k)) > 0) {
if (spa_streq(k, key)) {
if (spa_json_get_string(&it[1], value, len) <= 0)
continue;

View file

@ -75,7 +75,7 @@ static int match(const char *rules, struct spa_dict *dict, uint64_t *quirks)
int match = true;
uint64_t quirks_cur = 0;
while (spa_json_get_string(&it[0], key, sizeof(key)-1) > 0) {
while (spa_json_get_string(&it[0], key, sizeof(key)) > 0) {
char val[4096];
const char *str, *value;
int len;
@ -83,7 +83,7 @@ static int match(const char *rules, struct spa_dict *dict, uint64_t *quirks)
if (spa_streq(key, "quirks")) {
if (spa_json_enter_array(&it[0], &it[1]) > 0) {
while (spa_json_get_string(&it[1], val, sizeof(val)-1) > 0)
while (spa_json_get_string(&it[1], val, sizeof(val)) > 0)
quirks_cur |= parse_quirks(val);
}
continue;

View file

@ -942,7 +942,7 @@ int servers_create_and_start(struct impl *impl, const char *addresses, struct pw
if (spa_json_enter_array(&it[0], &it[1]) < 0)
return -EINVAL;
while (spa_json_get_string(&it[1], addr_str, sizeof(addr_str) - 1) > 0) {
while (spa_json_get_string(&it[1], addr_str, sizeof(addr_str)) > 0) {
res = parse_address(addr_str, &addrs);
if (res < 0) {
pw_log_warn("pulse-server %p: failed to parse address '%s': %s",

View file

@ -787,7 +787,7 @@ static int parse_params(struct impl *impl)
spa_json_init(&it[0], str, strlen(str));
if (spa_json_enter_array(&it[0], &it[1]) > 0) {
while (spa_json_get_string(&it[1], value, sizeof(value)-1) > 0) {
while (spa_json_get_string(&it[1], value, sizeof(value)) > 0) {
if (create_server(impl, value) == NULL) {
pw_log_warn("%p: can't create server for %s: %m",
impl, value);