ALSA: ump: Avoid dereference with max_src_size=0
PATCH 1/1 ALSA: ump: Avoid dereference with max_src_size=0
safe_copy_string() refers the source pointer for a NUL terminator before verifying the source size. When max_src_size=0, it may dereference wrongly. Fix the verification order.
Only hypothetical hardening, and we see no actual issue in the current code, as they are all valid sources.
Fixes e3f035edadcc ("ALSA: ump: Copy FB name string more safely")
Signed-off-by Takashi Iwai <[email protected]>
--- sound/core/ump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/ump.c +1 -1
@@ -66,7 +66,7 @@ static void safe_copy_string(void *dst, size_t max_dst_size,if (!max_dst_size--)return ; -for (s = src; max_dst_size && *s && max_src_size--; s++) { +for (s = src; max_dst_size && max_src_size-- && *s; s++) {if (!isascii (*s) || !isprint (*s))continue ; *d++ = *s;
Signature · 1 line
2.55.0