fix ManagementCommandFromInput()

pull/1/head
Heiko Hund 2012-07-20 11:56:08 +02:00
parent 3c81b7a4f2
commit 577d22dbc3
2 changed files with 9 additions and 6 deletions

13
misc.c
View File

@ -47,7 +47,7 @@ GetDlgItemTextUtf8(HWND hDlg, int id, LPSTR *str, int *len)
*len = 0;
ucs2_len = GetWindowTextLength(GetDlgItem(hDlg, id)) + 1;
if (ucs2_len == 0)
if (ucs2_len == 1)
goto out;
ucs2_str = malloc(ucs2_len * sizeof(*ucs2_str));
@ -77,7 +77,7 @@ out:
* Generate a management command from user input and send it
*/
BOOL
ManagementCommandFromInput(connection_t *c, LPSTR fmt, HWND hDlg, int id)
ManagementCommandFromInput(connection_t *c, LPCSTR fmt, HWND hDlg, int id)
{
BOOL retval = FALSE;
LPSTR input, cmd;
@ -95,9 +95,12 @@ ManagementCommandFromInput(connection_t *c, LPSTR fmt, HWND hDlg, int id)
}
/* Clear buffers with potentially secret content */
memset(input, 'x', input_len - 1);
SetDlgItemTextA(hDlg, id, input);
free(input);
if (input_len)
{
memset(input, 'x', input_len - 1);
SetDlgItemTextA(hDlg, id, input);
free(input);
}
return retval;
}

2
misc.h
View File

@ -22,7 +22,7 @@
#ifndef MISC_H
#define MISC_H
BOOL ManagementCommandFromInput(connection_t *, LPSTR, HWND, int);
BOOL ManagementCommandFromInput(connection_t *, LPCSTR, HWND, int);
BOOL streq(LPCSTR, LPCSTR);
BOOL wcsbegins(LPCWSTR, LPCWSTR);