[haiku-commits] r33442 - in haiku/trunk/src: add-ons/input_server/devices/keyboard kits/interface

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 5 Oct 2009 15:38:27 +0200 (CEST)

Author: mmlr
Date: 2009-10-05 15:38:27 +0200 (Mon, 05 Oct 2009)
New Revision: 33442
Changeset: http://dev.haiku-os.org/changeset/33442/haiku

Modified:
   haiku/trunk/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp
   haiku/trunk/src/kits/interface/Window.cpp
Log:
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.


Modified: 
haiku/trunk/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp   
    2009-10-05 13:27:39 UTC (rev 33441)
+++ 
haiku/trunk/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp   
    2009-10-05 13:38:27 UTC (rev 33442)
@@ -735,7 +735,7 @@
                        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;

Modified: haiku/trunk/src/kits/interface/Window.cpp
===================================================================
--- haiku/trunk/src/kits/interface/Window.cpp   2009-10-05 13:27:39 UTC (rev 
33441)
+++ haiku/trunk/src/kits/interface/Window.cpp   2009-10-05 13:38:27 UTC (rev 
33442)
@@ -1117,7 +1117,7 @@
                                        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 @@
                                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);


Other related posts:

  • » [haiku-commits] r33442 - in haiku/trunk/src: add-ons/input_server/devices/keyboard kits/interface - mmlr