Re: [RFC BlueZ 3/3] tools/btgatt-client: Add signed write support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Johan,

On Fri, Feb 20, 2015 at 12:55 PM, Johan Hedberg <johan.hedberg@xxxxxxxxx> wrote:
> 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]);

Yep, this sounds much much better.


-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux