From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Subject: [PATCH 2/2] shared/hfp: Fix for invalid string copy
Date: Thu, 30 Oct 2014 00:16:23 +0100 [thread overview]
Message-ID: <1414624583-29236-2-git-send-email-lukasz.rymanowski@tieto.com> (raw)
In-Reply-To: <1414624583-29236-1-git-send-email-lukasz.rymanowski@tieto.com>
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 f5a812d..f11f02c 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 {
--
1.8.4
next prev parent reply other threads:[~2014-10-29 23:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-29 23:16 [PATCH 1/2] shared/hfp: Remove reduntant check Lukasz Rymanowski
2014-10-29 23:16 ` Lukasz Rymanowski [this message]
2014-10-31 19:23 ` [PATCH 2/2] shared/hfp: Fix for invalid string copy Szymon Janc
2014-10-30 9:56 ` [PATCH 1/2] shared/hfp: Remove reduntant check Szymon Janc
2014-10-30 10:11 ` Marcin Kraglak
2014-10-30 15:09 ` Lukasz Rymanowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1414624583-29236-2-git-send-email-lukasz.rymanowski@tieto.com \
--to=lukasz.rymanowski@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox