From 6d8521b1f47b30b26157658c36cdd708321a5af0 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Tue, 7 Jul 2009 21:38:36 +0000 Subject: [PATCH] - Fix brackets to not perform a delete on a missing instance - Security checks on dissapeared devices git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31448 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/bluetooth/BluetoothServer.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/servers/bluetooth/BluetoothServer.cpp b/src/servers/bluetooth/BluetoothServer.cpp index 7b5458ba20..664c4d2635 100644 --- a/src/servers/bluetooth/BluetoothServer.cpp +++ b/src/servers/bluetooth/BluetoothServer.cpp @@ -154,9 +154,10 @@ void BluetoothServer::MessageReceived(BMessage *message) case BT_MSG_REMOVE_DEVICE: { LocalDeviceImpl* lDeviceImpl = LocateDelegateFromMessage(message); - if (lDeviceImpl != NULL) + if (lDeviceImpl != NULL) { fLocalDevicesList.RemoveItem(lDeviceImpl); delete lDeviceImpl; + } break; } @@ -200,7 +201,8 @@ void BluetoothServer::MessageReceived(BMessage *message) if (status != B_WOULD_BLOCK) { reply.AddInt32("status", status); message->SendReply(&reply); - printf("Sending reply message\n"); + printf("Sending reply message for->\n"); + message->PrintToStream(); } } @@ -333,6 +335,10 @@ status_t BluetoothServer::HandleSimpleRequest(BMessage* message, BMessage* reply) { LocalDeviceImpl* lDeviceImpl = LocateDelegateFromMessage(message); + if (lDeviceImpl == NULL) { + return B_ERROR; + } + const char* propertyRequested; // Find out if there is a property being requested, @@ -362,8 +368,11 @@ BluetoothServer::HandleGetProperty(BMessage* message, BMessage* reply) /* User side will look for the reply in a result field * and will not care about status fields, therefore we return OK in all cases */ - LocalDeviceImpl* lDeviceImpl = LocateDelegateFromMessage(message); + if (lDeviceImpl == NULL) { + return B_ERROR; + } + const char* propertyRequested; // Find out if there is a property being requested,