about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-02-19 20:16:33 +0000
committerJames Booth <boothj5@gmail.com>2012-02-19 20:16:33 +0000
commit35d224a2219f8acb9907825bca140e7400b63ba3 (patch)
treea42b773edd311ad0b77a6749b8dd7fd98f3f3784
parent3970a4d736813fd00a93bc8cccc09fd48283a38d (diff)
downloadprofani-tty-35d224a2219f8acb9907825bca140e7400b63ba3.tar.gz
Safe string handling on get password
-rw-r--r--command.c6
-rw-r--r--input_win.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/command.c b/command.c
index dce3ad5c..84ac8ad5 100644
--- a/command.c
+++ b/command.c
@@ -30,8 +30,8 @@ int handle_start_command(char *inp)
     }
     
     // trim input and take a copy
-    char inp_cpy[100];
     inp = trim(inp);
+    char inp_cpy[strlen(inp) + 1];
     strcpy(inp_cpy, inp);
     
     // get the command "/command"
@@ -70,8 +70,8 @@ int handle_command(char *inp)
     if (inp[0] == '/') {
 
         // trim input and take a copy
-        char inp_cpy[100];
         inp = trim(inp);
+        char inp_cpy[strlen(inp) + 1];
         strcpy(inp_cpy, inp);
 
         // get the command "/command"
@@ -131,7 +131,7 @@ static int _cmd_start_connect(char *inp)
 
         status_bar_get_password();
         status_bar_refresh();
-        char passwd[20];
+        char passwd[21];
         inp_get_password(passwd);
         int connect_status = jabber_connect(user, passwd);
         if (connect_status == CONNECTING)
diff --git a/input_win.c b/input_win.c
index 8adce620..cd911c9f 100644
--- a/input_win.c
+++ b/input_win.c
@@ -84,7 +84,7 @@ void inp_get_password(char *passwd)
 {
     wclear(inp_win);
     noecho();
-    mvwgetstr(inp_win, 0, 1, passwd);
+    mvwgetnstr(inp_win, 0, 1, passwd, 20);
     wmove(inp_win, 0, 1);
     echo();
     status_bar_clear();