linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Ido Yariv <ido@wizery.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Storage: Fix a buffer overflow in write_link_key
Date: Mon, 5 Mar 2012 12:01:29 -0800	[thread overview]
Message-ID: <20120305200129.GA17773@x220.ice.intel.com> (raw)
In-Reply-To: <1330971151-11075-1-git-send-email-ido@wizery.com>

Hi Ido,

On Mon, Mar 05, 2012, Ido Yariv wrote:
> The temporary string allocated on the stack is not large enough in worst
> case. To be on the safe side, increase it to 64 bytes.
> 
> Signed-off-by: Ido Yariv <ido@wizery.com>
> ---
>  src/storage.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/src/storage.c b/src/storage.c
> index a65cee4..7e7f081 100644
> --- a/src/storage.c
> +++ b/src/storage.c
> @@ -533,7 +533,7 @@ int write_lastused_info(bdaddr_t *local, bdaddr_t *peer, struct tm *tm)
>  
>  int write_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, uint8_t type, int length)
>  {
> -	char filename[PATH_MAX + 1], addr[18], str[38];
> +	char filename[PATH_MAX + 1], addr[18], str[64];
>  	int i;

I don't really see how the worst case you mention could ever happen in
practice. The key type requires one byte and 16 is the maximum for the
PIN length. Is there something I'm missing?

Johan

  reply	other threads:[~2012-03-05 20:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-05 18:12 [PATCH] Storage: Fix a buffer overflow in write_link_key Ido Yariv
2012-03-05 20:01 ` Johan Hedberg [this message]
2012-03-06  1:34   ` Ido Yariv

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=20120305200129.GA17773@x220.ice.intel.com \
    --to=johan.hedberg@gmail.com \
    --cc=ido@wizery.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;
as well as URLs for NNTP newsgroup(s).