On Fri, Apr 08, 2016 at 11:42:52AM +0200, Johnny Oskarsson wrote:
> From: Johnny Oskarsson <[email protected]>
> Date: Fri, 8 Apr 2016 10:39:50 +0200
> Subject: [PATCH 1/2] Initialize arrays to zero.
> 
> The uninizialized arrays caused some problems when selecting instrument
> number.
> ---
>  main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/main.c b/main.c
> index 1da3e04..a0a8ab6 100644
> --- a/main.c
> +++ b/main.c
> @@ -298,13 +298,13 @@ run(void)
>                                       XEvent e2;
>                                       KeySym tmpkeysym = NoSymbol;
>  
> -                                     char string[10];
> +                                     char string[10] = {0};
>                                       uint i = 0;
>                                       XSetForeground(dpy, gc, xfontcolor);
>  
>                                       while (tmpkeysym != XK_Return && 
> tmpkeysym != XK_KP_Enter) {
>                                               XNextEvent(dpy, &e2);
> -                                             char input[25];
> +                                             char input[25] = {0};
>  
>                                               switch (e2.type) {
>                                               case KeyPress:
> -- 
> 2.4.6
> 

> From: Johnny Oskarsson <[email protected]>
> Date: Fri, 8 Apr 2016 10:51:25 +0200
> Subject: [PATCH 2/2] Prevent buffer overflow when reading instrument number.
> 
> ---
>  main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/main.c b/main.c
> index a0a8ab6..4881905 100644
> --- a/main.c
> +++ b/main.c
> @@ -302,7 +302,9 @@ run(void)
>                                       uint i = 0;
>                                       XSetForeground(dpy, gc, xfontcolor);
>  
> -                                     while (tmpkeysym != XK_Return && 
> tmpkeysym != XK_KP_Enter) {
> +                                     while (i < sizeof(string)-1 &&
> +                                            tmpkeysym != XK_Return &&
> +                                            tmpkeysym != XK_KP_Enter) {
>                                               XNextEvent(dpy, &e2);
>                                               char input[25] = {0};
>  
> -- 
> 2.4.6
> 

Thank you, both patches apllied.

--
Regards,

Henrique N. Lengler

Reply via email to