Re: [dev] [svmidi] Minor fixes in instrument selection

From: Henrique N. Lengler <henriqueleng_AT_openmailbox.org>
Date: Fri, 8 Apr 2016 16:25:40 -0300

On Fri, Apr 08, 2016 at 11:42:52AM +0200, Johnny Oskarsson wrote:
> From: Johnny Oskarsson <joskar_AT_joskar.se>
> 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
> _AT_@ -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 <joskar_AT_joskar.se>
> 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
> _AT_@ -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
Received on Fri Apr 08 2016 - 21:25:40 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 08 2016 - 21:36:11 CEST