Here are some minor fixes in the input handling of instrument selection.

Regards,

Johnny Oskarsson
commit 21c6af2c68837207a31546fbaa09224fb89d5fc5
Author: Johnny Oskarsson <jos...@joskar.se>
Date:   Fri Apr 8 10:39:50 2016 +0200

    Initialize arrays to zero.
    
    The uninizialized arrays caused some problems when selecting instrument
    number.

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:
commit d9aea458f91748aff8c7ad8b9efc3aae66376d2b
Author: Johnny Oskarsson <jos...@joskar.se>
Date:   Fri Apr 8 10:51:25 2016 +0200

    Prevent buffer overflow when reading instrument number.

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};
 

Reply via email to