From: Takashi Iwai Subject: Re: [PATCH v2 6/7] topology: Add support for parsing vendor tuples Date: Tue, 05 Apr 2016 11:38:06 +0200 Message-ID: References: <6ceb0ce804d89c8d9cac5a1c80f1364041a8590f.1459321387.git.mengdong.lin@linux.intel.com> <5703515C.3070506@linux.intel.com> <57037D04.20604@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id B07DE265191 for ; Tue, 5 Apr 2016 11:38:07 +0200 (CEST) In-Reply-To: <57037D04.20604@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mengdong Lin 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 List-Id: alsa-devel@alsa-project.org On Tue, 05 Apr 2016 10:53:24 +0200, Mengdong Lin wrote: > > > On 04/05/2016 02:14 PM, Takashi Iwai wrote: > > On Tue, 05 Apr 2016 07:47:08 +0200, > > Mengdong Lin wrote: > >> > >> > >> > >> 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. > > > > Additional dependency is no-go, especially when the required change is > > so trivial. It's just a string copy, after all. > > > > Maybe we can just use strncpy(dest, src, 16), assuming the strncpy will > not try to write a "\0" at dest[16] that may cause overflow? You seem to think of things more complicated than needed. Just reread your code. What if a shorter string value is passed there to memcpy() call? That's what I suggested as an overflow. Takashi