diff mbox

[3/3] topology: Check address and length before string copy

Message ID d19561c620efa5ed81692a7441b8fa7354a800d4.1468917665.git.mengdong.lin@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

mengdong.lin@linux.intel.com July 19, 2016, 8:52 a.m. UTC
From: Mengdong Lin <mengdong.lin@linux.intel.com>

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

Comments

Lin, Mengdong July 19, 2016, 3:10 p.m. UTC | #1
> -----Original Message-----
> From: Takashi Sakamoto [mailto:o-takashi@sakamocchi.jp]
> Sent: Tuesday, July 19, 2016 5:45 PM
> To: mengdong.lin@linux.intel.com; alsa-devel@alsa-project.org;
> broonie@kernel.org
> Cc: tiwai@suse.de; Girdwood, Liam R; Lin, Mengdong
> Subject: Re: [PATCH 3/3] topology: Check address and length before string
> copy
> 
> Hi,
> 
> On Jul 19 2016 17:52, mengdong.lin@linux.intel.com wrote:
> > From: Mengdong Lin <mengdong.lin@linux.intel.com>
> >
> > Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> The cover letter addresses this patch fixes a compiler warning. In this case,
> it's better to write the message in commit message, I think. Like:
> http://mailman.alsa-project.org/pipermail/alsa-devel/2016-July/110097.ht
> ml
> 
> This is not just from my taste. Maintainers prefer. At least, blank commit
> messages are not preferrable in general.

Yes, that would be better. I'll fix this in v2 tomorrow.

Thanks
Mengdong

> 
> > diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
> > index 4d79aa7..cfde4cc 100644
> > --- a/src/topology/tplg_local.h
> > +++ b/src/topology/tplg_local.h
> > @@ -253,6 +253,9 @@ struct tplg_elem*
> tplg_elem_new_common(snd_tplg_t
> > *tplg,
> >
> >   static inline void elem_copy_text(char *dest, const char *src, int len)
> >   {
> > +	if (!dest || !src || !len)
> > +		return;
> > +
> >   	strncpy(dest, src, len);
> >   	dest[len - 1] = 0;
> >   }
> 
> 
> Regards
> 
> Takashi Sakamoto
diff mbox

Patch

diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index 4d79aa7..cfde4cc 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -253,6 +253,9 @@  struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
 
 static inline void elem_copy_text(char *dest, const char *src, int len)
 {
+	if (!dest || !src || !len)
+		return;
+
 	strncpy(dest, src, len);
 	dest[len - 1] = 0;
 }