From: Szymon Janc <szymon.janc@tieto.com>
To: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/2] shared/hfp: Fix for invalid string copy
Date: Fri, 31 Oct 2014 20:23:09 +0100 [thread overview]
Message-ID: <3005549.erq68NKaUk@leonov> (raw)
In-Reply-To: <1414624583-29236-2-git-send-email-lukasz.rymanowski@tieto.com>
Hi Łukasz,
On Thursday 30 of October 2014 00:16:23 Lukasz Rymanowski wrote:
> 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 {
Patch applied, thanks.
--
BR
Szymon Janc
next prev parent reply other threads:[~2014-10-31 19:23 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 ` [PATCH 2/2] shared/hfp: Fix for invalid string copy Lukasz Rymanowski
2014-10-31 19:23 ` Szymon Janc [this message]
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=3005549.erq68NKaUk@leonov \
--to=szymon.janc@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=lukasz.rymanowski@tieto.com \
/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