[PATCH 1/7] ALSA: ump: replace strlcat() with strscpy()
From: Mahad Ibrahim
Date: Fri Aug 07 2026 - 07:47:48 EST
When several function blocks map to the same group, their names are
joined with ", " and the separator was appended with strlcat().
Take the current length of group->name with strlen() and write the
separator at that offset with strscpy(), passing the space that is
left in the buffer.
group->name is NUL-terminated within its array, so the offset is
always less than the array size and at least one byte remains for
strscpy() to work with. Both functions stop at the end of the buffer,
so the string that comes out is the same.
Signed-off-by: Mahad Ibrahim <mahad.ibrahim.dev@xxxxxxxxx>
---
sound/core/ump.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sound/core/ump.c b/sound/core/ump.c
index 632c13baf21e..c6f55d2b8dc4 100644
--- a/sound/core/ump.c
+++ b/sound/core/ump.c
@@ -597,8 +597,11 @@ void snd_ump_update_group_attrs(struct snd_ump_endpoint *ump)
}
if (!*fb->info.name)
continue;
- if (*group->name)
- strlcat(group->name, ", ", sizeof(group->name));
+ if (*group->name) {
+ int len = strlen(group->name);
+
+ strscpy(group->name + len, ", ", sizeof(group->name) - len);
+ }
safe_append_string(group->name, sizeof(group->name),
fb->info.name, sizeof(fb->info.name));
}
--
2.54.0