From 81c431d23d8cc3d40ec1a9f3fdbcd45faba73839 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 5 Oct 2009 13:38:27 +0000 Subject: [PATCH] Include the terminating 0 byte when adding as string type. Otherwise someone reading the message as an actual string will run into problems. Should fix #4697. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33442 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../input_server/devices/keyboard/KeyboardInputDevice.cpp | 2 +- src/kits/interface/Window.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp index 41cb3430e2..b1e83644d9 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp @@ -735,7 +735,7 @@ KeyboardDevice::_ControlThread() if (numBytes > 0) { for (int i = 0; i < numBytes; i++) msg->AddInt8("byte", (int8)string[i]); - msg->AddData("bytes", B_STRING_TYPE, string, numBytes); + msg->AddData("bytes", B_STRING_TYPE, string, numBytes + 1); if (rawNumBytes <= 0) { rawNumBytes = 1; diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 721efee296..0093591d0c 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1117,7 +1117,7 @@ FrameMoved(origin); ssize_t bytes; if (msg->FindData("bytes", B_STRING_TYPE, (const void**)&string, &bytes) == B_OK) { - view->KeyDown(string, bytes); + view->KeyDown(string, bytes - 1); } } else target->MessageReceived(msg); @@ -1133,7 +1133,7 @@ FrameMoved(origin); ssize_t bytes; if (msg->FindData("bytes", B_STRING_TYPE, (const void**)&string, &bytes) == B_OK) { - view->KeyUp(string, bytes); + view->KeyUp(string, bytes - 1); } } else target->MessageReceived(msg);