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

2017-10-09 Thread Steven Rostedt
On Mon, 9 Oct 2017 16:27:10 -0600
Michael Sartain  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


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

2017-10-09 Thread Michael Sartain
On Mon, Oct 09, 2017 at 06:24:32PM -0400, Steven Rostedt wrote:
> On Sat, 12 Aug 2017 11:30:44 -0600
> Michael Sartain  wrote:
> 
> > Signed-off-by: Michael Sartain 
> > ---
> >  trace-output.c | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/trace-output.c b/trace-output.c
> > index bfe6331..84b21b0 100644
> > --- a/trace-output.c
> > +++ b/trace-output.c
> > @@ -929,7 +929,11 @@ tracecmd_add_option(struct tracecmd_output *handle,
> > free(option);
> > return NULL;
> > }
> > -   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.


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

2017-10-09 Thread Steven Rostedt
On Sat, 12 Aug 2017 11:30:44 -0600
Michael Sartain  wrote:

> Signed-off-by: Michael Sartain 
> ---
>  trace-output.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/trace-output.c b/trace-output.c
> index bfe6331..84b21b0 100644
> --- a/trace-output.c
> +++ b/trace-output.c
> @@ -929,7 +929,11 @@ tracecmd_add_option(struct tracecmd_output *handle,
>   free(option);
>   return NULL;
>   }
> - 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?

-- Steve

> +
>   list_add_tail(&option->list, &handle->options);
>  
>   return option;



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

2017-08-12 Thread Michael Sartain
Signed-off-by: Michael Sartain 
---
 trace-output.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/trace-output.c b/trace-output.c
index bfe6331..84b21b0 100644
--- a/trace-output.c
+++ b/trace-output.c
@@ -929,7 +929,11 @@ tracecmd_add_option(struct tracecmd_output *handle,
free(option);
return NULL;
}
-   memcpy(option->data, data, size);
+
+   /* Some IDs (like TRACECMD_OPTION_TRACECLOCK) pass NULL data */
+   if (data)
+   memcpy(option->data, data, size);
+
list_add_tail(&option->list, &handle->options);
 
return option;
-- 
2.13.2