Safe string handling on get password

This commit is contained in:
James Booth
2012-02-19 20:16:33 +00:00
parent 3970a4d736
commit 35d224a221
2 changed files with 4 additions and 4 deletions

View File

@@ -30,8 +30,8 @@ int handle_start_command(char *inp)
} }
// trim input and take a copy // trim input and take a copy
char inp_cpy[100];
inp = trim(inp); inp = trim(inp);
char inp_cpy[strlen(inp) + 1];
strcpy(inp_cpy, inp); strcpy(inp_cpy, inp);
// get the command "/command" // get the command "/command"
@@ -70,8 +70,8 @@ int handle_command(char *inp)
if (inp[0] == '/') { if (inp[0] == '/') {
// trim input and take a copy // trim input and take a copy
char inp_cpy[100];
inp = trim(inp); inp = trim(inp);
char inp_cpy[strlen(inp) + 1];
strcpy(inp_cpy, inp); strcpy(inp_cpy, inp);
// get the command "/command" // get the command "/command"
@@ -131,7 +131,7 @@ static int _cmd_start_connect(char *inp)
status_bar_get_password(); status_bar_get_password();
status_bar_refresh(); status_bar_refresh();
char passwd[20]; char passwd[21];
inp_get_password(passwd); inp_get_password(passwd);
int connect_status = jabber_connect(user, passwd); int connect_status = jabber_connect(user, passwd);
if (connect_status == CONNECTING) if (connect_status == CONNECTING)

View File

@@ -84,7 +84,7 @@ void inp_get_password(char *passwd)
{ {
wclear(inp_win); wclear(inp_win);
noecho(); noecho();
mvwgetstr(inp_win, 0, 1, passwd); mvwgetnstr(inp_win, 0, 1, passwd, 20);
wmove(inp_win, 0, 1); wmove(inp_win, 0, 1);
echo(); echo();
status_bar_clear(); status_bar_clear();