From 61142605f8026917b0b27c256f314d794af42866 Mon Sep 17 00:00:00 2001 From: Lukasz Rymanowski Date: Thu, 30 Oct 2014 00:16:23 +0100 Subject: [PATCH] shared/hfp: Fix for invalid string copy This part of code handles case when data in ring buffer are wrapped. In that case str is not a string so we shall not use asprintf but memcpy --- src/shared/hfp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/shared/hfp.c b/src/shared/hfp.c index 0ce38cc24..8f23ba2f0 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -447,7 +447,15 @@ static void process_input(struct hfp_gw *hfp) return; *ptr = '\0'; - count = asprintf(&ptr, "%s%s", str, str2); + + count = len2 + len; + ptr = malloc(count); + if (!ptr) + return; + + memcpy(ptr, str, len); + memcpy(ptr + len, str2, len2); + free_ptr = true; str = ptr; } else { -- 2.47.3