From ca10c6470f326031223c1335ee89b8967a1e4155 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 16 Feb 2021 15:07:40 +0100 Subject: [PATCH] audioconvert: use sizeof for position size And make the position field a little larger --- spa/plugins/audioconvert/merger.c | 7 ++++--- spa/plugins/audioconvert/splitter.c | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index b497db239..6376eba4b 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -209,12 +209,13 @@ static int init_port(struct impl *this, enum spa_direction direction, uint32_t p port->id = port_id; if (position < SPA_N_ELEMENTS(spa_type_audio_channel)) { - snprintf(port->position, 16, "%s", + snprintf(port->position, sizeof(port->position), "%s", spa_debug_type_short_name(spa_type_audio_channel[position].name)); } else if (position >= SPA_AUDIO_CHANNEL_CUSTOM_START) { - snprintf(port->position, 16, "AUX%d", position - SPA_AUDIO_CHANNEL_CUSTOM_START); + snprintf(port->position, sizeof(port->position), "AUX%d", + position - SPA_AUDIO_CHANNEL_CUSTOM_START); } else { - snprintf(port->position, 16, "UNK"); + snprintf(port->position, sizeof(port->position), "UNK"); } port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index 9844596a3..9e3cef180 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -76,7 +76,7 @@ struct port { struct spa_dict info_props; struct spa_dict_item info_props_items[2]; - char position[8]; + char position[16]; bool have_format; struct spa_audio_info format; @@ -158,12 +158,13 @@ static int init_port(struct impl *this, enum spa_direction direction, port->id = port_id; if (position < SPA_N_ELEMENTS(spa_type_audio_channel)) { - snprintf(port->position, 7, "%s", + snprintf(port->position, sizeof(port->position), "%s", spa_debug_type_short_name(spa_type_audio_channel[position].name)); } else if (position >= SPA_AUDIO_CHANNEL_CUSTOM_START) { - snprintf(port->position, 7, "AUX%d", position - SPA_AUDIO_CHANNEL_CUSTOM_START); + snprintf(port->position, sizeof(port->position), "AUX%d", + position - SPA_AUDIO_CHANNEL_CUSTOM_START); } else { - snprintf(port->position, 7, "UNK"); + snprintf(port->position, sizeof(port->position), "UNK"); } port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |