From: Johan Hedberg <johan.hedberg@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [RFC BlueZ 3/3] tools/btgatt-client: Add signed write support
Date: Fri, 20 Feb 2015 12:55:25 +0200 [thread overview]
Message-ID: <20150220105525.GA25329@t440s.lan> (raw)
In-Reply-To: <1424428710-8907-3-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Fri, Feb 20, 2015, Luiz Augusto von Dentz wrote:
> +static bool convert_csrk_key(char *optarg, uint8_t csrk[16])
> +{
> + int i;
> + char value[2];
> +
> + if (strlen(optarg) != 32) {
> + printf("csrk length is invalid\n");
> + return false;
> + }
> +
> + for (i = 0; i < 16; i++) {
> + strncpy(value, optarg + (i * 2), 2);
> + csrk[i] = strtol(value, NULL, 16);
It doesn't look like you've got enough space in 'value' for this. You'd
need 2 + 1 to have it nul-terminater. However, I think you can
completely get away with the need of this temporary variable by using
sscanf(), i.e. something like:
sscanf(optarg + (i * 2), "%2hhx", &csrk[i]);
Johan
next prev parent reply other threads:[~2015-02-20 10:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 10:38 [RFC BlueZ 1/3] shared/att.c: Add signing key support Luiz Augusto von Dentz
2015-02-20 10:38 ` [RFC BlueZ 2/3] shared/gatt-client: Add support for signed write Luiz Augusto von Dentz
2015-02-20 10:38 ` [RFC BlueZ 3/3] tools/btgatt-client: Add signed write support Luiz Augusto von Dentz
2015-02-20 10:55 ` Johan Hedberg [this message]
2015-02-20 11:47 ` Luiz Augusto von Dentz
2015-02-20 12:04 ` [RFC BlueZ 1/3] shared/att.c: Add signing key support Lukasz Rymanowski
2015-02-20 13:25 ` Luiz Augusto von Dentz
2015-02-20 13:40 ` Luiz Augusto von Dentz
2015-02-20 13:44 ` 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=20150220105525.GA25329@t440s.lan \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.