All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mengdong Lin <mengdong.lin@linux.intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, vinod.koul@intel.com,
	mengdong.lin@intel.com, broonie@kernel.org,
	rakesh.a.ughreja@intel.com, liam.r.girdwood@intel.com,
	hardik.t.shah@intel.com, subhransu.s.prusty@intel.com
Subject: Re: [PATCH v2 6/7] topology: Add support for parsing vendor tuples
Date: Tue, 5 Apr 2016 13:47:08 +0800	[thread overview]
Message-ID: <5703515C.3070506@linux.intel.com> (raw)
In-Reply-To: <s5hvb44770c.wl-tiwai@suse.de>



On 03/30/2016 03:35 PM, Takashi Iwai wrote:
> On Wed, 30 Mar 2016 09:11:17 +0200,
> mengdong.lin@linux.intel.com wrote:
>>
>> +		switch (type) {
>> +		case SND_SOC_TPLG_TUPLE_TYPE_UUID:
>> +			len = strlen(value);
>> +			if (len > 16 || len == 0) {
>> +				SNDERR("error: tuple %s: invalid uuid\n", id);
>> +				goto err;
>> +			}
>> +
>> +			memcpy(tuple->uuid, value, 16);
>
> This may still overflow :)
> How about simply using elem_copy_text()?

Sorry for the late reply.

Would you mind me using uuid_parse() here?
It can convert an input UUID string into the binary representation.

An UUID string link "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb" is user 
friendly for the text conf file. But this will add dependency on libuuid.

>
>> +		case SND_SOC_TPLG_TUPLE_TYPE_BYTE:
>> +		case SND_SOC_TPLG_TUPLE_TYPE_SHORT:
>> +		case SND_SOC_TPLG_TUPLE_TYPE_WORD:
>> +			tuple_val = strtol(value, NULL, 0);
>> +			if (tuple_val == LONG_MIN || tuple_val == LONG_MAX
>> +				|| (type == SND_SOC_TPLG_TUPLE_TYPE_WORD
>> +					&& tuple_val > 0xffffffff)
>
> Is the check correct on 32bit architecture?

I'll test on 32 bit machine and will use UINT/USHRT/UCHAR_MAX for range 
here.

>> +				|| (type == SND_SOC_TPLG_TUPLE_TYPE_SHORT
>> +					&& tuple_val > 0xffff)
>> +				|| (type == SND_SOC_TPLG_TUPLE_TYPE_BYTE
>> +					&& tuple_val > 0xff)) {
>
> Also, what about negative values?

I will add check, we don't expect to have negative value here.

Thanks again for your review.

Regards
Mengdong

>
> Takashi
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

  reply	other threads:[~2016-04-05  5:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30  7:09 [PATCH v2 0/7] topology: Add support for vendor tuples mengdong.lin
2016-03-30  7:10 ` [PATCH v2 1/7] topology: Use the generic pointer to free an element's object mengdong.lin
2016-03-30  7:10 ` [PATCH v2 2/7] topology: Define a free handler for the element mengdong.lin
2016-03-30  7:10 ` [PATCH v2 3/7] topology: Add doc for vendor tuples mengdong.lin
2016-03-30  7:11 ` [PATCH v2 4/7] topology: ABI - Define types " mengdong.lin
2016-03-30  7:11 ` [PATCH v2 5/7] topology: Add support for vendor tokens mengdong.lin
2016-03-30  7:11 ` [PATCH v2 6/7] topology: Add support for parsing vendor tuples mengdong.lin
2016-03-30  7:35   ` Takashi Iwai
2016-04-05  5:47     ` Mengdong Lin [this message]
2016-04-05  6:14       ` Takashi Iwai
2016-04-05  8:53         ` Mengdong Lin
2016-04-05  9:38           ` Takashi Iwai
2016-04-05 15:38             ` Lin, Mengdong
2016-03-30  7:11 ` [PATCH v2 7/7] topology: Build data objects with tuples mengdong.lin

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=5703515C.3070506@linux.intel.com \
    --to=mengdong.lin@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=hardik.t.shah@intel.com \
    --cc=liam.r.girdwood@intel.com \
    --cc=mengdong.lin@intel.com \
    --cc=rakesh.a.ughreja@intel.com \
    --cc=subhransu.s.prusty@intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@intel.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.