1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-12-08 23:33:07 +01:00

Fix double-free issue resulting crash

Note: webcam stuff doesn't work on Windows 2012. Work needs to be done to
make it work on this platform because the DX classes used to do the webcam
capture are not present on the system.
This commit is contained in:
OJ 2013-11-08 08:49:21 +10:00
parent 407fce7ef8
commit 016d24aec0
2 changed files with 16 additions and 12 deletions

View File

@ -171,13 +171,13 @@ void real_dprintf(char *filename, int line, const char *function, char *format,
#endif
/*! @brief Sets `dwResult` to the return value of `GetLastError()`, prints debug output, then does `break;` */
#define BREAK_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; }
#define BREAK_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d (0x%u)", str, dwResult, (ULONG_PTR)dwResult ); break; }
/*! @brief Sets `dwResult` to `error`, prints debug output, then `break;` */
#define BREAK_WITH_ERROR( str, err ) { dwResult = err; dprintf( "%s. error=%d", str, dwResult ); break; }
#define BREAK_WITH_ERROR( str, err ) { dwResult = err; dprintf( "%s. error=%d (0x%u)", str, dwResult, (ULONG_PTR)dwResult ); break; }
/*! @brief Sets `dwResult` to the return value of `WASGetLastError()`, prints debug output, then does `break;` */
#define BREAK_ON_WSAERROR( str ) { dwResult = WSAGetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; }
#define BREAK_ON_WSAERROR( str ) { dwResult = WSAGetLastError(); dprintf( "%s. error=%d (0x%u)", str, dwResult, (ULONG_PTR)dwResult ); break; }
/*! @brief Sets `dwResult` to the return value of `GetLastError()`, prints debug output, then does `continue;` */
#define CONTINUE_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); continue; }
#define CONTINUE_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d (0x%u)", str, dwResult, (ULONG_PTR)dwResult ); continue; }
/*! @brief Close a service handle if not already closed and set the handle to NULL. */
#define CLOSE_SERVICE_HANDLE( h ) if( h ) { CloseServiceHandle( h ); h = NULL; }

View File

@ -497,7 +497,7 @@ DWORD THREADCALL webcam_control_thread(THREAD * thread)
event_signal(state->pResultEvent);
break;
default:
dprintf("[WEBCAM] Unexpected action %u", state->dwAction);
dprintf("[WEBCAM] Unexpected action %u", (DWORD)state->controlAction);
state->bRunning = FALSE;
dwResult = ERROR_UNKNOWN_FEATURE;
break;
@ -689,22 +689,26 @@ DWORD request_webcam_start(Remote *remote, Packet *packet)
packet_transmit_response(dwResult, remote, response);
if (dwResult != ERROR_SUCCESS) {
dprintf("[WEBCAM] Failure found, cleaning up");
if (g_pWorkerThread != NULL) {
if (g_pThreadState != NULL) {
if (g_pThreadState->bRunning)
if (g_pThreadState->bRunning) {
thread_kill(g_pWorkerThread);
if (g_pThreadState->pCallEvent != NULL)
}
thread_destroy(g_pWorkerThread);
g_pWorkerThread = NULL;
if (g_pThreadState->pCallEvent != NULL) {
event_destroy(g_pThreadState->pCallEvent);
if (g_pThreadState->pResultEvent != NULL)
}
if (g_pThreadState->pResultEvent != NULL) {
event_destroy(g_pThreadState->pResultEvent);
}
free(g_pThreadState);
g_pThreadState = NULL;
}
thread_destroy(g_pWorkerThread);
free(g_pWorkerThread);
g_pWorkerThread = NULL;
}
}