summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2017-07-26 08:20:07 +0100
committerFrediano Ziglio <fziglio@redhat.com>2017-07-26 08:52:15 +0100
commitf00fe84cc34efe6d4e4f522ddcbdfbd538df6991 (patch)
tree9406c9a23959cd1fef3022c97231cd922e15a757
parent8512940e534ad090a9e66a8ecde4e6f243691e0d (diff)
Prevent possible future buffer overflow
event_type should come only with specific values but this in theory can change in the future. To prevent overflows (just for logging) check value size against lookup array. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe de Dinechin <cdupontd@redhat.com>
-rw-r--r--vdservice/vdservice.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 329f9c2..ec6243e 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -284,7 +284,8 @@ DWORD WINAPI VDService::control_handler(DWORD control, DWORD event_type, LPVOID
break;
case SERVICE_CONTROL_SESSIONCHANGE: {
DWORD session_id = ((WTSSESSION_NOTIFICATION*)event_data)->dwSessionId;
- vd_printf("Session %lu %s", session_id, session_events[event_type]);
+ vd_printf("Session %lu %s", session_id,
+ event_type < ARRAYSIZE(session_events) ? session_events[event_type]: "unknown");
SetServiceStatus(s->_status_handle, &s->_status);
if (event_type == WTS_CONSOLE_CONNECT) {
s->_session_id = session_id;