mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 09:12:24 +00:00
Fix potential buffer overrun in new saved-session menu
[originally from svn r267]
This commit is contained in:
parent
6693daa636
commit
0e3f5802b3
12
window.c
12
window.c
@ -627,6 +627,7 @@ static int WINAPI WndProc (HWND hwnd, UINT message,
|
|||||||
{
|
{
|
||||||
char b[2048];
|
char b[2048];
|
||||||
char c[30], *cl;
|
char c[30], *cl;
|
||||||
|
int freecl = FALSE;
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
HANDLE filemap = NULL;
|
HANDLE filemap = NULL;
|
||||||
@ -660,9 +661,12 @@ static int WINAPI WndProc (HWND hwnd, UINT message,
|
|||||||
sprintf(c, "putty &%08x", filemap);
|
sprintf(c, "putty &%08x", filemap);
|
||||||
cl = c;
|
cl = c;
|
||||||
} else if (wParam == IDM_SAVEDSESS) {
|
} else if (wParam == IDM_SAVEDSESS) {
|
||||||
sprintf(c, "putty @%s",
|
char *session = sessions[(lParam - IDM_SAVED_MIN) / 16];
|
||||||
sessions[(lParam - IDM_SAVED_MIN) / 16]);
|
cl = malloc(16 + strlen(session)); /* 8, but play safe */
|
||||||
cl = c;
|
if (!cl)
|
||||||
|
cl = NULL; /* not a very important failure mode */
|
||||||
|
sprintf(cl, "putty @%s", session);
|
||||||
|
freecl = TRUE;
|
||||||
} else
|
} else
|
||||||
cl = NULL;
|
cl = NULL;
|
||||||
|
|
||||||
@ -679,6 +683,8 @@ static int WINAPI WndProc (HWND hwnd, UINT message,
|
|||||||
|
|
||||||
if (filemap)
|
if (filemap)
|
||||||
CloseHandle(filemap);
|
CloseHandle(filemap);
|
||||||
|
if (freecl)
|
||||||
|
free(cl);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDM_RECONF:
|
case IDM_RECONF:
|
||||||
|
Loading…
Reference in New Issue
Block a user