[1/2] fix global variable out of boundary writing in libocl.

Submitted by Luo, Xionghu on June 12, 2015, 1:10 a.m.

Details

Message ID 1434071401-19966-1-git-send-email-xionghu.luo@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Luo, Xionghu June 12, 2015, 1:10 a.m.
From: Luo Xionghu <xionghu.luo@intel.com>

need minus one when fill '\0' to sizeof char type array.

Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>
---
 src/cl_extensions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/cl_extensions.c b/src/cl_extensions.c
index adcf82e..6b82b96 100644
--- a/src/cl_extensions.c
+++ b/src/cl_extensions.c
@@ -69,7 +69,7 @@  process_extension_str(cl_extensions_t *extensions)
   int str_offset = 0;
   int id;
 
-  extensions->ext_str[str_max] = '\0';
+  extensions->ext_str[str_max-1] = '\0';
 
   for(id = 0; id < cl_khr_extension_id_max; id++)
   {

Comments

Nice catch, LGTM, thanks.

On Fri, Jun 12, 2015 at 09:10:00AM +0800, xionghu.luo@intel.com wrote:
> From: Luo Xionghu <xionghu.luo@intel.com>
> 
> need minus one when fill '\0' to sizeof char type array.
> 
> Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>
> ---
>  src/cl_extensions.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/cl_extensions.c b/src/cl_extensions.c
> index adcf82e..6b82b96 100644
> --- a/src/cl_extensions.c
> +++ b/src/cl_extensions.c
> @@ -69,7 +69,7 @@ process_extension_str(cl_extensions_t *extensions)
>    int str_offset = 0;
>    int id;
>  
> -  extensions->ext_str[str_max] = '\0';
> +  extensions->ext_str[str_max-1] = '\0';
>  
>    for(id = 0; id < cl_khr_extension_id_max; id++)
>    {
> -- 
> 1.9.1
> 
> _______________________________________________
> Beignet mailing list
> Beignet@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
Pushed.

> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of

> Zhigang Gong

> Sent: Monday, June 15, 2015 10:18

> To: Luo, Xionghu

> Cc: beignet@lists.freedesktop.org

> Subject: Re: [Beignet] [PATCH 1/2] fix global variable out of boundary writing

> in libocl.

> 

> Nice catch, LGTM, thanks.

> 

> On Fri, Jun 12, 2015 at 09:10:00AM +0800, xionghu.luo@intel.com wrote:

> > From: Luo Xionghu <xionghu.luo@intel.com>

> >

> > need minus one when fill '\0' to sizeof char type array.

> >

> > Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>

> > ---

> >  src/cl_extensions.c | 2 +-

> >  1 file changed, 1 insertion(+), 1 deletion(-)

> >

> > diff --git a/src/cl_extensions.c b/src/cl_extensions.c index

> > adcf82e..6b82b96 100644

> > --- a/src/cl_extensions.c

> > +++ b/src/cl_extensions.c

> > @@ -69,7 +69,7 @@ process_extension_str(cl_extensions_t *extensions)

> >    int str_offset = 0;

> >    int id;

> >

> > -  extensions->ext_str[str_max] = '\0';

> > +  extensions->ext_str[str_max-1] = '\0';

> >

> >    for(id = 0; id < cl_khr_extension_id_max; id++)

> >    {

> > --

> > 1.9.1

> >

> > _______________________________________________

> > Beignet mailing list

> > Beignet@lists.freedesktop.org

> > http://lists.freedesktop.org/mailman/listinfo/beignet

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> http://lists.freedesktop.org/mailman/listinfo/beignet