Re: [PATCH 2/5] trace-cmd: Fix NULL pointer being passed to memcpy

From: Steven Rostedt
Date: Mon Oct 09 2017 - 18:34:06 EST


On Mon, 9 Oct 2017 16:27:10 -0600
Michael Sartain <mikesart@xxxxxxxxxxxx> wrote:

> > > - memcpy(option->data, data, size);
> > > +
> > > + /* Some IDs (like TRACECMD_OPTION_TRACECLOCK) pass NULL data */
> > > + if (data)
> > > + memcpy(option->data, data, size);
> >
> > Is this a problem, as when this happens, size should be zero. Does it
> > crash with data=NULL and size=0, or have you seen size not be zero?
>
> I got an ASAN warning, but you are correct - the size was 0 and it did
> not crash.

OK, but it's almost like dividing zero from zero. Can you send another
patch, but this time check if (size) instead of if (data).

-- Steve